Water keep filling til machine overflow and need to turn of water inlet valve
if you have to shut off the water supply valve of the residence (water keeps flowing after turning off the washing machine or unplugging the washer), the failed component is definitely a stuck open water inlet valve (fill valve) of the appliance. If the water stopped by pushing the timer or unplugging the machine, another internal electrical control related problem exists, such as a faulty timer assembly or controller board, or a pressure system failure (water level detection/monitoring system) - failed pressure switch (rare), clogged air hose or tub air dome (common in GE top-load washers), disconnected air hose (common in frigidaire top load washers & GE/Frigidaire/Kenmore stacked washer/dryer combo units).
While a simple repair can be done by yourself for a failed inlet valve, usually for $25-$50 in parts/shipping (go to searspartsdirect.com or appliancepartspros.com to look up a replacement fill-valve using your washing machine model number), the water damage potentially caused by the flooding is more important to address.
I recommend contacting your insurance company if there's a bunch of water that flooded your home - the water can cause delayed warping of flooring or cause mold to grow in/beneath your carpets and walls if the water was not immediately noticed and cleaned up (within first few minutes of flooding) - they send out water remediation specialists to dry (if possible), or to repair the damage to your home.