Most of the planets and moons that we are familiar with have solid surfaces. As a planet forms, gravity draws the the rocks and dust from which a planet is made together. When enough matter has been gathered, heat is released, and the planet may become a molten ball of melted material. Eventually the outside of the planet cools and begins to solidify and form a crust. As the crust solidifies it contracts, forming an uneven surface, with mountains, cliffs, rifts, and flat areas.
Cracks appear in the shell of the planet.
Hot material from the inside of the planet may escape, forming volcanoes, and meteors from space may crash on the planetary surface, creating craters. Steam may escape from the volcanic vents, and the icy parts of meteors may melt and add water. While the planet is hot, water exists as steam and rises in the atmosphere until it can form clouds, and, later, rain. Some of the water escapes into space, but on our planet, and possibly others, enough remains to support living beings. Meanwhile, the interior of the planet cools more slowly.