Why do moons orbit planets instead the sun ?
Everything in our solar system orbits the Sun. The moons are captured as their mass and proximity to the planets they orbit was low enough for the greater mass of the planet to overcome the pull of the Sun on those moons and bring them into orbit around the planet. And yes moons can and will break away from their planets and find a way back into orbit around the Sun independently or into collision with other planetary bodies or even catapulted out of the solar system given enough time.
the moons orbit planets because they are more strongly influenced by the planets pull than that of the sun. This is why plants close to the sun tend to have less or no moons while ones further away have more. They are also effected by the sun – earth for example orbits the sun, and so does the moon in a sence because its following the orbit of the earth around aswell as orbiting the earth. The definition of a planet is a large body on mass that orbits the sun and does NOT cross the path of any other planets – (this is why pluto is no longer a planet). I suppose it is possible if a huge meteor hit the moon it could be knocked off course, but the chances that it manged to create its own orbit without colliding are tiny.