Few appliance mishaps are as dramatic as an overflowing washer. A leaking valve on the water inlet valve assembly can allow the washer to fill constantly even with the washer turned off. Unplug the washer and see if water still flows into the washer. If so, then you'll need to replace the water inlet valve assembly.
A faulty water-level pressure switch can cause the washer to overfill during the cycle. The water level pressure switch is a component of the main electronic control board on some washers. Replace the water-level pressure switch or main electronic control board if the washer overfills during the cycle, but stops filling when you turn the washer off.