Notice in Luke 3 the lineage goes back to Nathan. Marys lineage goes back to Davids son Nathan.
Luke 3:31 Which was the son of Melea, which was the son of Menan, which was the son of Mattatha, which was the son of Nathan, which was the son of David,
Then notice in Matthew 1 the lineage goes back to Davids son Solomon.
:6 And Jesse begat David the king; and David the king begat Solomon of her that had been the wife of Urias;
Both Mary and Joseph go back to David each through a different son of David.
Mary is not mentioned in either Luke 3 or Matthew 1. The only way to bring Mary into the lineage discussion is to assume that one of the two different men identified as Joesph's father (Jacob in Matthew and Heli in Luke) is actually Mary's father and therefore Joseph's father-in-law.
This poses an insoluble dilemma for Protestants who choose to rely only on Scripture when presented with a question that cannot be answered from "Scripture Alone".
How do you know this about Mary?
Where does Scripture give the names of Mary’s parents or say that Mary is a descendent of the house of David?
It seems that because there are slight differences in the lists, an assumption has been made that it must be that the reason is that one is that of Joseph and one is that of Mary.
But, Scripture never says this does it?
There are a myriad of theories as to the reason for the differences, but any theory must be extra Biblical speculation because the Bible itself gives no reason for the disparities.