The question is asked, "Well, how did Moses receive God's words to write them down?" The process is called inspiration. In II Timothy 3:16, Paul said that all Scripture is God breathed (or inspired, depending on your translation). By this, Paul means that our entire Bible comes from the mouth of God. God told the various writers what to say and they then told the people and wrote the words down. A good illustration of this is found in Exodus 4:10-16. Moses was looking for an excuse not to do what God wanted him to do. His last excuse was that he was not a good speaker. God scolded him, but then told him that Moses' brother Aaron would be the spokesman. God would tell Moses what needed to be said. Moses would then tell Aaron and Aaron would then tell the people. Verse 16 is the interesting verse. Moses' action with Aaron would be like God's action with Moses.
How God told the people what to say varied greatly, especially during the time before the New Testament. In Hebrews 1:1-2, the writer said that God spoke at different times and in different ways in the past. Sometimes he spoke to people in dreams, such as in Genesis 20:3. At other times he gave people a special dream that represented what they needed to know, such as in Genesis 37:5-10. God also used visions. A vision is seeing something that is not physically there. It would be sort of like a waking dream. An example of this can be found in Genesis 15:1. Sometimes God would send an angel to deliver his message, such as in Matthew 1:18-24. Another method that God used was prophets. A prophet was a spokesman for God. God would deliver a message to the prophet and the prophet would then deliver the message to the proper person. Moses was a prophet, but he held a special place. God did not use cryptic dreams with him or using sayings that were difficult to understand. God spoke plainly and directly with Moses just as a person would speak to his friend. (Numbers 12:6-8.)
Moses and the prophets that came after him, wrote the things that God taught them down into books. The book of Genesis is one of five books that Moses wrote. The other books are Exodus, Leviticus, Numbers, and Deuteronomy. These five books are the first five books in our Old Testament. Because of the frequent use of the phrase "these are the records of" in Genesis, some scholars believe that Moses had access to the earlier writings of these people; either with a physical copy, or by God giving him knowledge of what these people wrote. Moses then compiled these separate records into a single book that we call Genesis.
In the New Testament, Jesus is the source of all our teachings. He talked to the apostles directly while he was on earth. Many of these teachings are recorded in the books that we call the Gospels. Gospel means "good news." The first four books of the New Testament, Matthew, Mark, Luke, and John, are the Gospels. After Jesus died on the cross, he sent the Holy Spirit to guide the apostles in his teachings (John 16:13). The Holy Spirit made it possible for the disciples to accurately remember everything that Jesus taught while he was on earth (John 14:26). The disciples then wrote what the Holy Spirit taught them into the books that we call the New Testament.
Because of this use of people to relay God's word, we find places in the Bible where the writings of a person is quoted, but we are told that God said the quoted statement or that the Holy Spirit said the quoted statement. For example, in Hebrews 3:7, the writer quotes Psalms 95:7 and says that these are the words of the Holy Spirit. Yet later, in Hebrews 4:7, the writer refers to the same quote and says that these are the words of David. Both statements are true because the Holy Spirit gave the words to David who then wrote them down in a psalm.