The number of moons a planet has is determined by various factors, including the planet's formation process, its size, and its gravitational interactions with other objects. Moons can be captured asteroids or the result of collisions with other objects.