“The books of Scripture firmly, faithfully, and without error teach [the] truth. . . . Written under the inspiration of the Holy Spirit, they have God as their author” (Second Vatican Council, DV 11).
The Bible did not fall from heaven in its final form, nor did God dictate it to human scribes who copied it down mechanically. Rather “God chose certain men who . . . made full use of their own faculties and powers so that, though he acted in them and by them, it was as true authors that they consigned to writing whatever he wanted written, and no more” (Second Vatican Council, DV 11).
One factor in recognizing particular texts as Sacred Scripture was their general acceptance in the Church. In the Christian communities there had to be a consensus: “Yes, through this text God himself speaks to us—this is inspired by the Holy Spirit!” Which of the many original Christian writings are really inspired by the Holy Spirit has been defined since the fourth century in the so-called canon of Sacred Scriptures.