Here's what I found.
Luke 3:23-38
23Now Jesus himself was about thirty years old when he began his ministry. He was the son, so it was thought, of Joseph,
the son of Heli, 24the son of Matthat,
the son of Levi, the son of Melki,
the son of Jannai, the son of Joseph,
25the son of Mattathias, the son of Amos,
the son of Nahum, the son of Esli,
the son of Naggai, 26the son of Maath,
the son of Mattathias, the son of Semein,
the son of Josech, the son of Joda,
27the son of Joanan, the son of Rhesa,
the son of Zerubbabel, the son of Shealtiel,
the son of Neri, 28the son of Melki,
the son of Addi, the son of Cosam,
the son of Elmadam, the son of Er,
29the son of Joshua, the son of Eliezer,
the son of Jorim, the son of Matthat,
the son of Levi, 30the son of Simeon,
the son of Judah, the son of Joseph,
the son of Jonam, the son of Eliakim,
31the son of Melea, the son of Menna,
the son of Mattatha, the son of Nathan,
the son of David, 32the son of Jesse,
the son of Obed, the son of Boaz,
the son of Salmon,[a] the son of Nahshon,
33the son of Amminadab, the son of Ram,
the son of Hezron, the son of Perez,
the son of Judah, 34the son of Jacob,
the son of Isaac, the son of Abraham,
the son of Terah, the son of Nahor,
35the son of Serug, the son of Reu,
the son of Peleg, the son of Eber,
the son of Shelah, 36the son of Cainan,
the son of Arphaxad, the son of Shem,
the son of Noah, the son of Lamech,
37the son of Methuselah, the son of Enoch,
the son of Jared, the son of Mahalalel,
the son of Kenan, 38the son of Enosh,
the son of Seth, the son of Adam,
the son of God.
So, this should help explain it.
Mary was a direct descendant of King David which gave Jesus the right to ascend the Jewish throne, both through Mary and through adoption by his foster father, Joseph. Mary’s genealogy is supplied in Luke 3:23-38 . Dr. Henry Morris explains the genealogy in Luke:
“Joseph was clearly the son of Jacob (Matthew 1:16, so this verse [Luke 3:23 - says “son of Heliâ€Â] should be understood to mean “son-in-law of Heli.†Thus, the genealogy of Christ in Luke is actually the genealogy of Mary, while Matthew gives that of Joseph. Actually, the word “son†is not in the original, so it would be legitimate to supply either “son†or “son-in-law†in this context. Since Matthew and Luke clearly record much common material, it is certain that neither one could unknowingly incorporate such a flagrant apparent mistake as the wrong genealogy in his record. As it is, however, the two genealogies show that both parents were descendants of Davidâ€â€Joseph through Solomon (Matthew 1:7-15), thus inheriting the legal right to the throne of David, and Mary through Nathan (Luke 3:23-31), her line thus carrying the seed of David, since Solomon’s line had been refused the throne because of Jechoniah’s sin†[Dr. Henry M. Morris, The Defender’s Study Bible, note for Luke 3:23 (Iowa Falls, Iowa: World Publishing, Inc., 1995).].