If you read carefully, every time the canon was defined, some of the authors were specified. Between the various councils & papal statements, the authors for all NT books were specified. Of course, anyone can insert into those statements supposition that authorship was not intended by those statements, but that is an unsubstantiated supposition based on modern prejudices.
It is like when the bible says Moses wrote about Jesus, and modern scholars try to come back and say Moses did not write the Pentateuch. When you insert all these modern suppositions into ancient texts, you really leave no room for them to say what they were trying to say. You cannot really expect them to have had the foresight to say, e.g., ‘The letters of Paul - even though we know someone later on will deny he wrote them!’ Maybe they should also have included a just-in-case clause for those who deny Paul existed, and one for those who deny John wrote Revelation etc. There are a lot of suppositions we have that they did not.