According to the Bible, it came from the rains, and when God opened "the fountains of the deep".
As far as where it went...apparently, the pre-flood earth had more land and shallow seas. Under the great pressure of a global flood, the Earth buckled...areas (now the deapest parts of the Oceans) were lowered, and mountains and other high lands were raised, leading to the flood water catastrophically receding. This explains many things we see today, including the continental shelf areas (with canyons, similar to the grand canyon)and sea shells on high mountains.