Venus from space
For several hundred million years after the Big Bang, there were no planets, only stars. Planets couldn't form until the first stars ran out of fuel and exploded into supernovas, about 14 billion years ago. The supernovas spewed out thousands of tons of carbon, oxygen, iron and other elements into space. Planets are made out of the recycled atoms of old stars.
New stars formed wherever these atoms in space got a little thicker, and gravity began to pull them together. When the clouds of atoms got heavy and hot enough at their centers, that set off nuclear fusion and made a new star. But around the outside of these stars, you still had the thinner edges of the clouds floating around. The gravity of the star in the middle, through centrifugal force, pulled these thin clouds into orbit around the star.
Little by little, the whirling clouds around the star got thicker in some places and thinner in others. Where they were thicker, more atoms stuck together. The heaviest atoms, iron, ended up making the centers of planets, while the lighter atoms, like hydrogen, carbon, oxygen and helium, ended up on the surface. Because gravity pulled evenly in all directions, the planets were generally shaped like spheres. The first planets may have formed around 14 billion years ago, but not all planets formed then. The planets that go around our Sun, including Earth, probably formed only around 4.5 billion years ago, and new planets are still forming today around other stars.
Some planets formed closer to their star, and others formed further away. A planet that was close to a star was hotter, of course, but also usually smaller and harder, made mostly of iron, like our planets Mercury, Venus, Earth, and Mars. Planets that formed farther away from their star were colder, larger, and softer, made mostly of hydrogen, like our planets Jupiter, Saturn, Uranus, and Neptune. We call these "gas giants". There are planets around many other stars besides the Sun, and like our planets some of them have water on them, and organic molecules like methane, but we don't know yet whether there is anything alive on them.