Why are the genealogies of Jesus different?

Supposed Bible contradiction – Matthew’s genealogy verses Luke’s genealogy. In the different Gospels of Matthew and Luke, we are given the genealogies of Joseph, the adopted father of Christ. However, they differ on who the father of Joseph was. Matthew says Jacob was the father of Joseph and has a line going back to Abraham but Luke says Heli is the father of Joseph and has a line going back to Adam. These are not different names of the same people; they are completely different genealogies. So do we have a contradiction?

The most common argument is the genealogy of Luke was Mary’s line. Heli was the father of Mary who became the father-in-law of Joseph, thus making Joseph his son as well. This would be consistent with the idea that some scholars have suggested, that Luke used a relative of Mary’s side of the family as a source for his birth narrative.  So he would have taken that genealogy instead and since there was no Greek word for “son-in-law”, Joseph was simply called the “son” of Heli (Luke 3:23). That is perfectly acceptable by most scholars as there is no indication Mary had any brothers but only a sister (John 19:25). Thus, if there were no sons of Heli, Joseph would become the legal heir to Heli’s inheritance, thus his heir by law. This would also make sense with the fact that Mary wedded within the family of David to ensure Heli’s inheritance remained among those of the same household which is in accordance with the laws of Numbers 36:1-12.