N.T. Wright in his book “The Last Word” is discussing the topic, did they know they were writing scripture (John 20:31)

This is not to say, of course, that the writers of the New Testament specifically envisaged a time when their books would be collected together and form something like what we now know as the canon. I doubt very much if such an idea ever crossed their minds. But that they were conscious of a unique vocation to write Jesus-shaped, Spirit-led, church-shaping books, as part of their strange first-generation calling, we should not doubt.