Logically that is a good question, but this descent was symbolic. It was about theological emphasis. The genealogies emphasize aspects of the authors' viewpoints, and how they are trying to portray what Jesus was about. Unfortunately I can neither remember nor find the specific explanation I've always heard. If you research the matter online you'll find several.
L. Michael White, in From Jesus to Christianity, strangely doesn't discuss the matter, for all I have heard him in Austin, Texas, where he lives and teaches, tell us what the explanations of the two genealogies are.
According to Robin Griffith-Jones, the Four Witnesses, Matthew's genealogy emphasizes Jesus as the Jewish Messiah, descended from David. Luke's genealogy traces him back to David differently, but the emphasis is on his descent from Adam; all of mankind will be redeemed through him.
Another popular explanation says that Matthew's is the genealogy of his adoptive father that makes him heir to the Messiahship, and the other is a roundabout genealogy of his mother, but I'm not satisfied there's a reason why for that.