Usually this question is framed in an argument that goes something like this. “The Gospels were originally written anonymously and only after a century or so were authors assigned to each Gospel to give lend them much needed authority.” This idea has gained so much steam recently that it has become cited as fact, while providing very little in the way of evidence to back it up.
So, what evidence is there that the Gospels were or were not originally anonymous? If you research the earliest manuscripts of each of the Gospels, you will find each one has an author attributed to it. In fact, we currently do not possess a single copy of any Gospel that is indeed anonymous from antiquity. Dating all the way back to the second century, each manuscript we possess attributes each Gospel to the authors as we know them today. Dr. Brant Pitre in his book “The Case for Jesus” also points out that unlike the Letter to the Hebrews, which we know to be written anonymously, we have no record of any one of the four Gospels being attributed to someone other than the traditional authors. Copies of the Letter of the Hebrews, on the other hand, have been attributed to St Paul, St Luke, St Barnabas, and a number of other potential authors. We simply do not find that phenomenon with the Gospels, although we would expect to if they were indeed originally written anonymously and then assigned names at a much later date.
In short, while you will find the idea that the Gospels were anonymous written thrown about wildly in an attempt to discredit them, this hypothesis is simply not rooted in the facts from the historical record we possess.