As for the OT, the motivation to codify and record the traditions in writing was the Babylonian captivity. Most of it existed as oral tradition with bits and pieces written down in various forms but was by no means codified or standardized before then. The most interesting thing to look at is to see the evolution of the creation accounts-all three of them-the two most are familiar with from Genesis and the third from Psalms and the Noah story. The third creation account was written in the reign of David, the other two written down in the period of the Babylonian captivity. The first is free of all influence of Sumerian/Babylonian elements, the two from Genesis and the Noah tale, are rife with Sumerian/Babylonian elements, beginning with but not ending with the flood account of Noah, an element that was absent from pre-Babylonian Captivity tradition.
There is a large body of work examining the evolution of the OT stories. One of the earliest is Sir George Frazier's (of Golden Bough fame) Folklore in the Old Testament, but there is a lot more recent scholarship as well. I haven't dipped into that well much in the last 10-15 years, but I worked with a couple of scholars who specialized in it when I was in grad school and kept abreast of the work on it for a while before more pressing concerns drew my attention elsewhere.