Scientists believe that terrestrial planets, like Earth, formed by clumping together from dust and gas into into hot blobs of molten metal and rock several billion years ago. After becoming distinct planets, they went through four stages of formation: Differentiation, Cratering, Flooding and Surface Evolution. For Earth, these changes led to the planet we know today, layered with an iron core, a weathered, shifting surface, water and life.
TL;DR (Too Long; Didn't Read)
A newly-formed terrestrial planet, such as the Earth or Venus, goes through four distinct stages of development: Differentiation, Cratering, Flooding and Surface Evolution.
Differentiation - Layer Formation
As a body becomes large enough to attract planetesimals en masse and become a planet, the energy generated by the frequent impacts begins a process of differentiation, whereby the material separates according to density. Dense materials migrate to the core, attracted by gravity, whereas finer materials form the crust and early atmosphere. The process is complex. Dense materials may separate out like drops of water and drop through the crust, while fluids and molten materials rise buoyantly through the crust, forming veins and fissures. Differentiation happens because the system seeks to minimize gravitational energy.
Cratering - Impacts and Scars
The crust of the newly formed planet eventually cools, but the bombardment of planetesimals that created it in the first place continues, and because the planet is no longer molten, the impacts form craters. Some of the impacts may burst through the crust to the molten mantle. In the early stages of planetary formation, the number of impacts is very high, as evidenced by Mercury and the moon, two bodies with old surfaces that have been largely unchanged since they were formed. Both planets are saturated with craters.
Sciencing Video Vault
Flooding - Lava Covers Everything
While cratering is still occurring -- and partly as the result of it -- the crust of a planet fractures, and lava bursts through and flows over the land, smoothing the craters and filling them. In the case of Earth, water vapor also flowed through the fissures during this stage of planetary formation. It rose into the atmosphere and fell to the ground as rain, forming the oceans and other bodies of water. Water flooding didn't accompany lava flooding on other planets in the solar system. On these planets, the effects of lava flooding are more apparent.
Surface Evolution - Changing Landscape
The last stage of planetary formation, surface evolution, lasts for billions of years. The face of the planet is slowly altered by the movement of tectonic plates and the effects of atmospheric movements and water. The collision of tectonic plates pushes up mountains and shifts continents, while rain and wind slowly wear away the surface and remove all traces of chaotic early stages of planetary formation. In the case of Earth, radioactivity in the core actually makes it hotter than it was when it formed, which may be one of many reasons why the conditions to support life evolved.