The first five books of the Bible (Genesis to Deuteronomy) were not all written by the same person. They were not even redacted (edited) by one person. Scholars tend to identify four redactors, known as J-E-D-P, which stand for Jawist, Elohist, Deuteronomist, and Priestly, respectively. Their narratives are interspersed throughout the Pentateuch (first five books of the Bible), and are the reason we have two versions of various stories.
As with almost everything in the Bible, there is a great deal of debate surrounding the JEDP theory. I suggest you do your own research and come to your own conclusions.