A Ball Valve is the device that prevents water from flowing into the toilet and controls the flow of water into a toilet when it is flushed. It is called a Ball Valve because it is a Valve with a hollowed spherical disc at its centre.
When the handle of the Valve is pulled (the toilet is flushed) the hollow at the centre of the disc lines up with the ends of the Valve and water flows through the device. When the Valve returns to its original position, the Valve closes and the flow of water is cut off.
There are many different types of Ball Valve but their mechanics are all essentially that which has been described.