A charlie horse is caused by an interruption in communication in the body.
Most of the time your muscles run smoothly, whether you're resting in the dugout or dodging foul balls in the stands. Your brain constantly monitors muscle positions via signals traveling up the spinal cord. Before you wind up at the mound, your prefrontal cortex plans the pitch (curve ball? slider?) and signals the motor cortex to send impulses back down your spinal cord to the appropriate muscles.
Unfortunately, hiccups can happen anywhere in this sequence. The brain's monitoring process can get interrupted. Or a few motor neurons might overreact to a signal. This often happens when the muscle is prevented from getting the nutrients it needs, so expect cramps during states of exercise and dehydration.
Why do we call a sudden arm or leg cramp a "Charlie horse?" The term's origins stretch back to late 19th-century baseball slang, but the exact source is as clouded as a dusty slide into home plate.