Crap I misread your question, I thought you said how do you get it. Well the reason you get diarrhea is because its your body's way of flushing itself out. Its the one of the fastest ways to get rid of all the foods and toxins out of your body.
Diarrhea is a very common symptom and has literally thousands of different causes. It can be caused by anything from infections, to sudden changes in diet, to allergic reactions, to excessive fluid intake, etc.
Do you mean how the process works in your body or the causes for it. There can be various reasons, diet, irritable bowel syndrome, a stomach bug, stress etc. If it's been going on for a while consult a doctor.
It is best to look at your diet, here is a link that may help.
Unbalanced dieting .