The genealogy in Matthew is through Mary, it just isn’t as apparent because of a lack of cultural understanding in the English translations. Matt 1:16 literally says “Joseph the man of Mary” (Greek andra). This Greek word can mean ‘husband’ but doesn’t have to mean ‘husband’, it is just a generic word for ‘man’, similar to the Hebrew word ish. In Matt 1:19, it refers to Joseph as Mary’s aneer, a different word that can also mean either ‘man’ or ‘husband’. So why the difference? In the Aramaic version of Matthew, the term in Matt 1:16 is gowra which is a little bit more specific of a term; it means ‘male guardian of’. Joseph was a very common name in that time period so based on this evidence it appears that the Joseph in Matthew 1:16 is not the same Joseph that is her husband, but in fact either her father or perhaps a brother who served as her male guardian (if her father was deceased at that time). Remember that Mary and Joseph were not married at the time of conception!
The genealogy in Luke 3 is claimed to be through Mary by many scholars, but the verse doesn’t state that…it states the opposite! Luke 3:23 “being, as was supposed, the son of Joseph, the son of Eli. First, the Joseph gowra of Mary from Matt 1 was the son of Jacob, not Eli, thus proving the above point. Second, the underlined word above is the Greek word enomizeto which is from the word nomos or ‘law’. A literal translation would be “being, according to the law, the son of Joseph, the son of Eli”. Mary’s husband Joseph would have legally adopted Yeshua as his son after birth, thus making Yeshua to be Joseph’s son, according to the law! Thus Luke’s genealogy must be the genealogy of Joseph, the adoptive father of Yeshua, not that of Mary!