Steve Ray has a list of 35 loaded Questions for "Bible Christians" (quotation marks his)(link to the whole list). This is number 8/35. I'm trying to provide the answers in a common format, for easy reference.
8) How do we know who wrote the books that we call Matthew, Mark, Luke, John, Acts, Hebrews, and 1, 2, and 3 John?
1) We don't know, but we have good historical reasons to assign authorship for all of those books besides Hebrews. We don't know who wrote Hebrews, and we're mostly guessing about who the author is.
2) It doesn't really matter who wrote those books. We also don't know who wrote Esther, the books of the kings and Chronicles, and many of the psalms. We still accept them as the Word of God.