Dear Student
It is based on the third law of motion which states that for every action there is an equal and opposite reaction. As the water comes out of the sprinkler, an equal and opposite reaction force comes into play. So the sprinklers start rotating.
Regards