Genealogies were always reckoned through the father (Moses’ sons were Levites, though Zipporah was not from Israel), and Jesus considered himself descended from David (Mt. 22:43-45). Now the two genealogies of Jesus in Matthew and Luke are actually the same in various places, especially the early parts, and sometimes the genealogies only “hit the high spots,” i.e. only give the names that are considered important. Also, names often had variants, so “Matthan” might be the same person as “Matthat.” So the genealogies might just overlap, with different people highlighted, it is possible, though a tight fit in some places.But more satisfactorily, there might have been adoption, or some other similar circumstance, and thus two lines recorded by the different gospels, along the lines of what Eusebius writes here: “The second century historian Julius Africanus, a native of Israel, records information given by Christ’s remaining family in his day. According to their family genealogy, Joseph’s grandfather Matthan (mentioned in Matthew) married a woman named Estha, who bore him a son named Jacob. After Matthan died, Estha married his close relative Melchi (mentioned in Luke) and bore him a son named Heli. Jacob and Heli were thus half-brothers.” “But Heli died childless, and so Jacob married his widow and fathered Joseph, who was biologically the son of Jacob but legally the son of Heli” (Eusebius, Ecclesiastical History 1:6:7).
Now the Greek word for “was the father of” (KJV: “begat”) ordinarily means the direct parent of a person, however, it need not always mean that: Hebrews 11:12 And so from this one man, and he as good as dead, came descendants [the same word translated “was the father of / begat” in Mt. 1] as numerous as the stars in the sky and as countless as the sand on the seashore.