Billions of years ago, space consisted of several cosmic dust particles roaming around. They stick together to form bigger particles of dust.
They add onto each other's size until the particles form a sphere. Due to the excess amounts of these cosmic dust particles, the sphere's surface temperature is hotter than burning iron!
The young planet is full with liquids at this stage. The planet is constantly hit by meteorites , making it boil with an enormous amount of heat. This happens until the meteorites slow down and the earth calms down.
At this stage, the earth starts to change. It separates the various elements within the planet, and proceeds to form layers as shown above.
It is important to note that there are still heat spots present inside the planet. There is an enormous amount of rain to cool the planet entirely and form oceans all over the planet.
The volcanos deep inside the oceans release hot magma, which cools down and forms island on top of the water. These islands become continents over time. And that is the earth we know today!