They didn't reproduce by masturbation. It's called asexual reproduction.
Or, you could realize that older creation myths from the same area that Genesis came from (Mesopotamia) feature a God (the Sun-God, Atum) who masturbated other beings into existence (Shu and Tefnut: goofy names, huh? Not a serious name like Yahweh!).
I kinda like the God who masturbated thing: it certainly explains ALOT about the internet, LOL!
Instead, the Bible completely side-steps the "who created Yahweh?" question by essentially saying, "Never mind that: Yahweh just always WAS, OK?" There's plenty of similarities between the creation Genesis myth and the others, including the above one, and with the Greeks.