I understand that Moses wrote Genesis, but he was not around when God created the world. So from where and whom did he get the information how God created the world in 6 days?
While the Bible itself is silent on the matter, two plausible answers have been proposed.
First, Moses' knowledge of the origins of the world could have been passed to him through a process of oral history from Adam to Moses. Due to the extremely long lifespans of early humanity, very few generations were required to pass this knowledge over thousands of years. For example, only two people are required to connect the lifespan of Adam to Abraham:
Adam —> Lamech —> Shem —> Abraham
Since Adam had first-hand knowledge of much of Creation (and the rest could have been communicated to Him by God), then it’s plausible that the story was repeated and passed down through these few generations. To move the account from Abraham to Moses would require only four more generations. Therefore, an oral history of the world could have been passed down from Adam to Moses through Noah’s family.
A second answer comes from the writings of the first century Jewish historian, Josephus. He claims that Methuselah was an ancient historian of his day, who recorded the history of the world (as told by Adam) on stone obelisks. These obelisks were carried by Noah onto the ark, and after the ark came to rest, Noah deposited the stone tablets in Arabia.
Later during the desert wanderings, Moses was directed by God to discover these obelisks, where he learned the history of the world and repeated it in the Jewish scripture. The obelisk was written in Hebrew (which was the first language of mankind), so only a Jewish man like Moses could have deciphered it.
While we have no proof of either scenario, we do see the result found in scripture. Self-evidently, the Lord found a means for transferring the knowledge of origins to Moses, and as a matter of faith, we believe in the testimony of the Bible. Furthermore, the content of Genesis validates itself, being consistent with the rest of scripture.