This is called backflow. The cause of this problem can be as simple as leaving a hose in a pool or bucket of cleaning water or by not having appropriate air gaps between water-supply outlets and flood-level rims.
Prevention of backflow is an important step in pool maintenance. When filling a pool with a water hose, for example, be sure that the faucet is equipped with a hose bib vacuum breaker. This is known as a mechanical solution, which helps maintain an air gap and keeps water flowing in the proper direction.
But not all piping is continuous. In this case, theres a much simpler, non-mechanical solution. Simply be sure that there is an open space — greater than one inch and at least twice the diameter of the water-supply outlet — between the water-supply outlet and the flood level rim.
Local authorities regulate the prevention of backflow in swimming pools and hot tubs. When building or maintaining a pool, check with these regulations for guidance.