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.
Be careful when working on a water valve. You may have serious liability issues confronting you.
Electrical Failures
The second cause involves failure 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 may be restricted by sludge or a water drop. Front loaders use very little water; consequently the pressure switch is not working very hard and rarely fails.