Eusibius in Church History Book 1 quoted Africanus explaining the discrepancies of Jesus genealogy.
2. For whereas the names of the generations were reckoned in Israel either according to nature or according to law—according to nature by the succession of legitimate offspring, and according to law whenever another raised up a child to the name of a brother dying childless; for because a clear hope of resurrection was not yet given they had a representation of the future promise by a kind of mortal resurrection, in order that the name of the one deceased might be perpetuated—
3. whereas then some of those who are inserted in this genealogical table succeeded by natural descent, the son to the father, while others, though born of one father, were ascribed by name to another, mention was made of both of those who were progenitors in fact and of those who were so only in name.
4. Thus neither of the gospels is in error, for one reckons by nature, the other by law. For the line of descent from Solomon and that from Nathan were so involved, the one with the other, by the raising up of children to the childless and by second marriages, that the same persons are justly considered to belong at one time to one, at another time to another; that is, at one time to the reputed fathers, at another to the actual fathers. So that both these accounts are strictly true and come down to Joseph with considerable intricacy indeed, yet quite accurately.
5. But in order that what I have said may be made clear I shall explain the interchange of the generations. If we reckon the generations from David through Solomon, the third from the end is found to be Matthan, who begot Jacob the father of Joseph. But if, with Luke, we reckon them from Nathan the son of David, in like manner the third from the end is Melchi, whose son Eli was the father of Joseph. For Joseph was the son of Eli, the son of Melchi.
6. Joseph therefore being the object proposed to us, it must be shown how it is that each is recorded to be his father, both Jacob, who derived his descent from Solomon, and Eli, who derived his from Nathan; first how it is that these two, Jacob and Eli, were brothers, and then how it is that their fathers, Matthan and Melchi, although of different families, are declared to be grandfathers of Joseph.
7. Matthan and Melchi having married in succession the same woman, begot children who were uterine brothers, for the law did not prohibit a widow, whether such by divorce or by the death of her husband, from marrying another.
8. By Estha then (for this was the woman’s name according to tradition) Matthan, a descendant of Solomon, first begot Jacob. And when Matthan was dead, Melchi, who traced his descent back to Nathan, being of the same tribe but of another family, married her as before said, and begot a son Eli.
9. Thus we shall find the two, Jacob and Eli, although belonging to different families, yet brethren by the same mother. Of these the one, Jacob, when his brother Eli had died childless, took the latter’s wife and begot by her a son Joseph, his own son by nature and in accordance with reason. Wherefore also it is written: ‘Jacob begot Joseph.’ Ma tthe w 1:6 But according to law he was the son of Eli, for Jacob, being the brother of the latter, raised up seed to him.
*
17. Thus far Africanus. And the lineage of Joseph being thus traced, Mary also is virtually shown to be of the same tribe with him, since, according to the law of Moses, intermarriages between different tribes were not permitted. For the command is to marry one of the same family and lineage, so that the inheritance may not pass from tribe to tribe. This may suffice here.*
To sum it up, Matthew showed the genealogy according to Nature and Luke by Law. Mary is in the same tribe since according to the law of Moses intermarriages between tribes were prohibited.