How did erupting volcanoes contribute to the formation of oceans?
In layman's terms, most theories agree that Earth used to be hot, molten ball of rock, gas and metal.
The formation of many volcanoes is also widely accepted as a phase a young Earth went through during its early years.
However, these volcanoes, when erupting, would provide a channel for water vapour and other gases to escape from the molten interior of the Earth.
As many recent events show, even minor volcanic eruptions may cause fluctuations in the average temperature of the Earth's atmosphere and these are nothing compared to the scale of volcanic activity billions of years ago.
Volcanic activity back then would easily have been violent enough to lower global temperatures by a lot, cooling down the average temperature below the boiling point of water (unsurprisingly, there a lot of theories explaining this) and allowing escaped water vapour in the atmosphere to cool down, basically causing a rain to fall for years and years without end, creating our first primeval oceans.
Therefore, erupting volcanoes contribute a lot to the formation of oceans, even though it certainly seems counterintuitive.