This is a very complicated question! I'll try to be as clear as possible.
Tides are the culprit. A moon feels a gravitational pull from its planet. That pull is stronger on the moon's near side than on its far side, so the moon gets pulled into a slightly elongated shape. (The moon exerts the same sort of differential pull on the Earth, which is why we have ocean tides.)
The longest axis of the moon stays pointed at the planet, but the moon still be turning. As it rotates, different parts of it bulge out. For example, the Moon raises a tidal bulge in the ocean of the Earth on whatever part of the Earth is pointed at the Moon. As the Earth turns, the bulge moves over the surface, starting, for example, with high tides in the Pacific, then in the Indian Ocean, then in the Atlantic -- but always lined up with the Moon.
A moon on an inclined (tilted) orbit, passing above and below the equator of the planet, will have its tidal bulge constantly moving up and down. The movement of the bulge leads to friction and heat. That friction acts to try to stop the moon from going up and down, that is, decrease its inclination, or make it orbit around the equator of the planet.
It takes less than a billion years for tidal friction to make the orbit of most moons equatorial. If a moon is in an inclined orbit, then astronomers have a puzzle to solve. Either something (like the gravity of another moon) is working to keep the moon's orbit tilted, or maybe the moon was captured recently so tides haven't had time to get it into an equatorial orbit.