A dishwasher filling with water overnight or when not in use has two possible causes. Either the water is running into the washing machine from the sink (if the drain hose is connected directly to the sink) or one of the water valves isn't shutting off properly and water is dripping slowly but surely into the washing machine. The latter problem can take several hours before the water level rises high enough inside the washing machine to be visible.
It's easy to track down the cause of water entering the dishwasher when not in use. If turning off the hot and cold water taps stops it, then it's one of the water valves not shutting off properly, and needs replacing. With a hot and cold fill machine it's just a process of elimination to find out which one it is.
If you are working on a dishwasher then the valve that is causing the problem will probably look something like this, and will be located under the dishwasher where the water connection is. This is what the valve looks like if you take it apart to clean it. If the right kind of dirt, like sand gets through the screen and gets embedded in the seat of the valve, it will hold it open slightly, causing it to leak.
By taking it apart you may be able to get the debris out of the valve seat and get it to close fully again.
If the water does not even slow up when you unplug or turn off the power, then the valve has totally come apart inside and cleaning it will not help you. You will need to replace the valve if that happens.
Washing machine valves are very similar, but are a double valve, one side is hot and the other is cold. If you have water running in your washing machine, when it should not be, then you need to determine if it is the hot or the cold water that is running. Then you can also possibly fix the washing machine valve by taking it apart and cleaning it also, just like the dishwasher valve.
Some of the newer washing machines may also have valves that look very different because they mix the water to a temperature as it is going in. If you have one of these valves they are much more complicated to take apart to clean. If you try to take one of these valves apart, pay very close attention to how it comes part so that you can get it back together again.
The main thing to remember when looking to find out why the water will not shut off going into yourdishwasher or washing machine, is that the electrically operated valve may not be able to shut off completely if there is debris caught inside the valve. Finding out if the valve closes some, but not completely will tell you if the problem will require just a cleaning or a complete replacement of the valve.