How can I prevent my washing machine's drain hose from detaching from the pipe?
It's possible that it just fell out.  Repeated heat/cool cycles plus the force of the water exiting the hose could have broken the bond to the duct tape.  

The duct tape could be serving two purposes.


To hold the hose into the drain pipe.  Judging by the amount of tape this may not be the first time it has happened.
If there is no trap in the drain line, the duct tape could be a DIY attempt to block sewer gas from escaping.