Here's a breakdown:
* Formation: The Sun formed first, pulling in material from the protoplanetary disk. As this disk cooled and condensed, gravity pulled together clumps of dust and gas, eventually forming planetesimals. These planetesimals collided and merged, growing larger and larger until they became planets.
* Moons: Moons formed in a similar way, either from material around the newly formed planets or from collisions with other celestial bodies.
* Gravity: All the planets and moons are bound together by the Sun's gravity. The Sun is the most massive object in the solar system, its gravitational pull keeps everything in orbit around it.
So, in essence, planets and moons are part of our solar system because they were born from the same material and are held together by the same gravitational force. They are all part of a single, interconnected system that has been evolving for billions of years.