Luke’s genealogy is Mary’s and Matthew’s is Joseph’s. The word “supposed” in Luke 3:23 in “enomizo” which is commonly translated as “supposed,” but has as its root the word “nomos” which is the word law. Joseph was the a son-in-law or a “supposed son.”
Further discussion of this was in my dissertation.
“The second problem is trickier. If the Bible is a divinely inspired book without a single error or contradiction, what is Joseph doing with two incompatible family trees?”
This is a non-problem. You are defining “error or contradiction” with some sort of assumption that these are history books, or science experiments. But Christian tradition has never considered them such (except for certain modern schismatics, who call themselves Protestants). You are imposing categories that didn’t exist until maybe the Renaissance.
Luke was probably emphasizing descent from Adam, the father of humanity, to show the universality of the Savior. Matthew seems to be interested in the Davidic kingship over Israel. Neither one of them was trying to be what we would call a “genealogist,” (another modern idea) so it is an error to dismiss them by that standard.
It is equally an error to accept them by that standard, by insisting that the two genealogies can be reconciled by this or that recondite means. That’s the same modern rationalist confusion.