Here is a good article that explains it. Interestingly coffee promotes the urge to poop in at least one-third of the population and tends to impact women more than men.
Only coffee does this to me though. It's got to be a combination of things. I know coffee is higher in caffeine than most other drinks, but I sometimes take a caffeine pill, which is even higher, and it has never caused the coffee shits.