How Were the Books of the Bible Chosen?

It is believed by Christians that God choose certain prophets to speak to and for them to write the books. Others wrote books (ex. lost scrolls) but they were not spoken to by God. Only the ones that were spoken to by God, did their books go into the bible.