Raymond E. Brown says, in An Introduction to the New Testament, page 236, that while Luke's list may be less classically monarchical than Matthew's, there is little likelihood that either is strictly historical. On this view, there is no mistake and no misunderstanding of Jewish genealogies. Brown notes that many try to reconcile the two very different genealogies by saying that they are indeed historical, but that Matthew's is the genealogy back through Joseph and Luke's goes back through Mary - in spite of Luke 3:23!
Luke 3:23: And Jesus himself began to be about thirty years of age, being (as was supposed) the son of Joseph, which was the son of Heli
Joachim Jeremias, in Jerusalem, page 290, says both gospels give the ancestry of the carpenter Joseph, and both try to show his Davidic origin, noting that ancient and modern attempts to see one as Mary's genealogy have all failed. On page 296, Jeremias reports that the custom of using the names of the twelve patriarchs as personal names did not arise until after the exile, so when Luke cites the names of Joseph, Judah, Simeon, and Levi as descendants six to nine, it is an anachronism that proves at least that the pre-exilic portion of Luke's genealogy has no historical value.
On the evidence of Raymond Brown, Joachim Jeremias and many others, the genealogies in both Matthew and Luke are portrayed as that of Joseph. Therefore it can be said that in Matthew, Joseph's father was Jacob, while in Luke his father was Heli. Brown says (page 176) that Matthew's Joseph is shaped in the image of the patriarch Joseph, another son of Jacob, because both interpret dreams and save the family by going to Egypt. There are many parallels between Matthew's flight to Egypt and the Old Testament sojourn in Egypt.