You do not mention a problem or the make & model of your machine.
It works by agitating the clothes in water with detergent. Then rinsing to remove the dirty water and detergent and usually followed by draining and spinning. The draining is achieved by a pump.
The sequence of events is automatic - on early machines controlled by motor driven cams and switches and electronically in modern machines.
More here...
http://en.wikipedia.org/wiki/Washing_machine
Peccavi
May 2011