An asteroid can have a moon due to the gravitational interactions between the asteroid and another object. When two objects come close to each other in space, their gravitational forces can affect each other. If the gravitational force is strong enough, it can cause a smaller object to be captured as a moon by the larger object.
In the case of asteroids, if they encounter another smaller object in their vicinity, such as a smaller asteroid or a captured space rock, the larger asteroid can capture it as its moon. This capture can occur through various mechanisms, such as gravitational attraction or a collision that results in the smaller object being trapped in orbit around the larger asteroid.
It's important to note that these moons of asteroids are significantly smaller in size compared to the moons of planets like Earth's Moon. They are typically irregularly shaped and much smaller in scale.