See, I'm going to ruin some of it for you guys.
Around the time the books were written, the Jewish religious leaders changed the stories in order to calm the people a little bit and to tell them basically whatever they wanted to do, which is why a lot of the stories don't fit. They were written by several different authors, even in the context of the same book.
Then, after that, the Romans did the same thing to the New Testament around the time of Constantine. It makes perfect sense. No sex before marriage? That just curves the birth rate of oppressed people groups so that they don't outnumber the tyrants.
Perfect sense. The Bible, which has a verse in it about not changing it under the penalty of death, has been changed millions of times in order to oppress people or to enforce a moral code decided by humanity.