The answer is quite lengthy, thus the reason I provided a link, but I’ll highlight a one quick item from the link as to why the lineage is traced through Joseph and not Mary. It’s my understanding that St. Matthew’s Gospel in particular was written to a primarily Jewish audience:
Jewish law required that genealogies were to be through the line of the males, and not the females
DISCLAIMER: Catholic Answers has turned over the archive to Catholic-Questions.org and no longer owns, manages, or moderates the forums. For additional apologetics resources please visit www.catholic.com.