Our star, the sun, belongs to the generation of stars created 4.6 billion years ago from a cloud of interstellar gas and/or dust (the "solar nebula"). Something happened (possibly a shock wave from a nearby supernova) to disturb this nebula and it collapsed under its own gravity. The collapse of the nebula caused it to heat up and compress in the center. This all occurred within a 100,000 year timespan.
Most of the gas/dust was pulled to the center and compressed enough to become a protostar. More gas flowed inward and added to the mass of the forming star, which was rotating. The centrifugal force from that rotation kept some of the rest of the material of the nebula from reaching the star. A small fraction of the material in the disk formed solids which bumped into each other, stuck and grew larger. As they grew larger, their gravity increased. These larger particles were able to attract even more dust and ice, increasing in size to become the cores of planets, moons or asteroids. Some drifted away from the sun to become comets.
These processes took millions of years and the birth of the solar system continued for millions more years to end up with the planets we know. These planets were further groomed by other forces, such as collisions and radiation. So, even though the planets were all formed from the same materials, they are not the same.
The sun still contains most of the material of the original solar nebula. Its internal nuclear reactions have modified the material at the suns core. However, the surface layers, which have not mixed with the core in its present state, have quite accurately preserved the original nebular composition.

