Answer
There is no contradiction because these are partly two different genealogies.
Explanation
Luke gives the list right from Adam and Matthew gives the list from Abraham.
The list is the same from Abraham to David in both Matthew and Luke.
However, the genealogies move away in two different directions from David onwards.
“These are the names of those born to him (King David) in Jerusalem:
Shammua, and Shobab, and Nathan, and Solomon” (2 Sam 5:14).
Matthew continues the list from King David through King Solomon (Matthew 1:6) while Luke does so through Nathan (Luke 3:31)
So, Jacob and Heli cannot be half-brothers.
Multiple names of Heli/Jacob for the same person also cannot solve the issue because, as is clear, these are two different genealogies; one from King Solomon and the other from Nathan.
Comparison of the Two
One thing is sure:
Jacob is the biological father of Joseph, the husband of Mary:
“Jacob then begat (Greek – egenneisan = procreated) the Joseph the
husband of Mary” (biblehub).
This is according to Matthew.
Luke simply says:
“Joseph of the Heli of the Maththat” etc (Luke 3:23-24).
Now, Joseph can be of Heli in different ways:
Could be a biological son;
Could be an adopted son;
Could be a son-in-law; etc.
Conclusion
So, it is clear that Matthew gives the biological genealogy of Joseph through King Solomon.
Luke gives the genealogy of Joseph through his marital alliance with Mary’s family.
Since these are two different genealogies from David through Solomon and Nathan, there is no room for any contradiction.