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.
Where it went, was the rising of the continents. There is evidence of plates that the mantle of the Earth slides on, these plates could be the source of the breaking points where the water from below came from, shooting up between the cracks so to speak. With the underground water going up, the land mass that was once resting/floating on the water would go down, causing the water to overrun the land. When the plates slid togethor in spots, like our continents we see, the land mass in those areas would rise enough from collision to form dry land higher that the water.
Notice also, the Bible says it rained 40 days on the land, but the waters still rose after 40 days, this would have to be the underground waters released by the fountains of the deep opening up.
We still believe that mountain ranges are caused by these plates colliding and buskling higher. Since according to Naoh's flood all land would be under water, it explains why there are fossils on top of Everest and the Rocky's.