An overfilling washer, whether a top or front loader, has really only two causes.
Mechanical Failure
First and by far the most common is a bad fill valve; one that fails to shut off when power is removed.
"I unplugged my washer and the water kept coming! I had to turn off the faucets."
A fill valve is a delicate device that needs pure water to properly function. Any debris getting into the valve can stop the internal seals from working. Folks remove the inlet strainers, because of frequent clogging or slow filling, grit gets into the valve, jams the internal ports and it fails to shut off.
Never remove the strainers; always, either squirt them clean, or replace the valve. You may have serious liability issues confronting you.
Electrical Failures
The second cause involves proper operation of the pressure switch. This delicate switch shuts off the water valve once the correct level is attained and confirmed by measuring pressure in the air line.
Pressure switches seldom fail; however, the air signal to the pressure switch is often restricted by sludge or a water drop. GE is famous for getting a drop of water in the pressure switch line that causes problems.
Whirlpool is prone to clogging at the inlet of the airdome.
In many cases you must pull the basket to properly clean the dome. This can be very difficult.
Always carefully check the air dome and air line before ordering a switch. It must be unkinked, clean. dry and easy to blow through and make the switch click. Also the water level must be drained below the dome inlet each time you check for proper fill level. With low water pressure and a slow fill, this may take considerable time.
Computerized Pressure Switches
Whirlpool redesigned their standby pressure switch to a much more complex one. Instead of only three wires, it has many more. This design causes very odd intermittent fill and flood problems. The symptoms can be misleading. If you see the following style pressure switch replace it before concluding that you have a bad timer.