When the Earth was young it was very hot, so the water released by volcanoes stayed in the atmosphere as water vapour, which is a gas.
As the Earth gradually cooled, the water vapour began to cool as well. Cooling a gas turns it into a liquid, and this change is called condensation. The water vapour condensed into liquid water.
The liquid water fell as rain and collected in hollows on the Earth's surface. Over a very long time this formed the oceans. If the Earth had stayed too hot, the water would have stayed as vapour and no oceans would have formed.