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.
The two separate accounts of Jesus lineage back to David cannot both be true of Joseph.