You don't include many details other than the washer is overfilling and flooding the house but most likely the problem is with the water level switch.
The first thing to consider is does the water shut off when you turn the washer off. If the washer is overfilling and you turn the power off or unplug the washer and it continues to fill then the water valve is bad and needs to be replaced.
If the valve shuts off when the power is turned off then the valve is okay and the problem is most likely with the water level switch.
The image below shows how to access the pressure switch. Remember to unplug the washer first. If you have a volt/ohm meter you can check the switch. There are 3 wires on the pressure switch. The yellow/black is the common wire bringing voltage to the switch and it either feeds to the brown wire to start a fill or it feeds to the violet wire to start agitation. There is no middle ground. The washer will fill or agitate but it shouldn't do both.
If the switch checks okay then you will need to check the plastic hose located on the pressure switch. If the hose has a pin hole or is kinked so no pressure gets to the water level switch to trip it from fill to agitate then it can be causing this problem. PUll the hose off the switch and blow through it towards the tub. If you can't blow through it then the air dome is clogged and is causing the overfilling.
If the washer continues to fill one other trick to check this problem is to simply unplug the water level switch while it is filling with water. If it stops filling then the pressure switch is most likely the problem but if it keeps filling with the pressure switch unplugged then the timer is the problem.
I hope this information helps to resolve this problem but submit another question with any additional details for further assistance.