Both Matthew 1:2 and Matthew 1:15 refer to Jacob- however they are not the same person.
Beginning with Matthew 1:2, we have a genealogy for Jesus starting with Abraham. Matthew wrote his gospel originally in Hebrew, according to early Christians, for Jewish Christians primarily. Tracing the genealogy of Jesus back to father Abraham would be a reasonable thing to do for his audience. (Luke later wrote to Gentiles, and extended the genealogy back to Adam.)
Matthew begins — Abraham, then his son Isaac, then his son Jacob. In verse 2, when Matthew says “Jacob begat Judas and his brethren,” he means Judah (as it is spelled in the Old Testament), the fourth son of Jacob’s wife, Leah.
“And his brethren” refers to the other 11 sons of Jacob who, together with Judah, generated the 12 tribes of Israel.
In verse 15, we are now to the end of the listing, just before Jesus. In this case also there is a person named Jacob, but of course this is not the same Jacob as mentioned in verse 2. Jacob in verse 15 is many generations later. In verse 15, Jacob’s son was Joseph, the husband of Mary, who was the mother of Jesus.
The father of this much later Joseph was a person named Matthan.