How do I prevent my washing machine stand pipe from overflowing?
There could be a blockage downstream somewhere. However, there would    probably be a lot more water on the floor and on a regular basis.    Check the height of the stand pipe. If it is not tall enough, the    water will run out of it when you have more water in the tub than you    normally use. I/E: If you normally wash a small load but sometimes    you run a super sized load.

Also, it looks like that piping is fairly old. Washing machines have much stronger pumps than they did years ago and the stand pipe height requirements for your particular washer might be different than what you have. Lengthening the height of the stand pipe might help.

You could also install a flood-guard, which is a type of back water valve. This one can be added inline by inserting it into the pipe, tightening three screws and you're done. Any water attempting to back up in the line will be prevented from entering your home.