"All Scripture is breathed out by God and profitable for teaching, for reproof, for correction, and for training in righteousness, that the man of God may be competent, equipped for every good work" (2 Timothy 3:16-17).
As I have studied the Bible over the years, I have noticed at least three ways that God has used in inspiring the Scriptures.
1. Sometimes God dictates the words. For example, see Exodus 20:1-17.
2. Sometimes God communicates his message in dreams and visions that are recorded by prophets. For example, see Daniel 7:1.
3. Sometimes God leads the author of a biblical book through careful research. For example, see Luke 1:1-4.
God has chosen different methods, but still "all Scripture is breathed out by God" (2 Timothy 3:16). Those who gave us the Scriptures "were carried along by the Holy Spirit" as they communicated God's message to us (2 Peter 1:21). And those Scriptures can be trusted because they came from a God "who never lies" (Titus 1:2).