The Old Testament books were written well before Jesus’ Incarnation, and all of the New Testament books were written by roughly the end of the first century A.D. But the Bible as a whole was not officially compiled until the late fourth century, illustrating that it was the Catholic Church who determined the canon—or list of books—of the Bible under the guidance of the Holy Spirit. Indeed, the Bible is not a not a self-canonizing collection of books, as there is no table of contents included in any of the books.
Although the New Testament canon was not determined until the late 300s, books the Church deemed sacred were early on proclaimed at Mass, and read and preached about otherwise. Early Christian writings outnumbered the 27 books that would become the canon of the New Testament. The shepherds of the Church, by a process of spiritual discernment and investigation into the liturgical traditions of the Church spread throughout the world, had to draw clear lines of distinction between books that are truly inspired by God and originated in the apostolic period, and those which only claimed to have these qualities.
The process culminated in 382 as the Council of Rome, which was convened under the leadership of Pope Damasus, promulgated the 73-book scriptural canon. The biblical canon was reaffirmed by the regional councils of Hippo (393) and Carthage (397), and then definitively reaffirmed by the ecumenical Council of Florence in 1442.
Finally, the ecumenical Council of Trent solemnly defined this same canon in 1546, after it came under attack by the first Protestant leaders, including Martin Luther.