I think it is to do with the fight or flight reflex. When posed with something making us nervous/scared, one of the reflexes is to shift blood etc. away from the digestive system, and to our skeletal muscle so we can evade the stimuli. In extreme cases of fear, this could mean the loss of control over the lower end of our digestive system, and cause excretion!