Unfortunately no one totally understands what causes muscle cramps. Most authorities agree that in skeletal muscles they are frequently caused by the hyper-excitability of the nerves that stimulate muscles. Rather than thinking of a single cause of muscle cramps, I find it more helpful to think in terms of risk factors.
A field study of 433 Ironman triathletes suggest that those so cramped had exercised harder than usual, had a family history of cramping and had previous tension or ligament damage. Because muscle cramps often occur due to muscle fatigue the problem may be related to nerve malfunction creates an imbalance between muscle excitation and inhibition which prevents the muscle from relaxing. (see Schwellnus et al 2004).
In summary although muscle cramps are likely to be related to overexertion there are other contribution factors.
Shang G, Collins M and Schwellnus M (2001). Factors associated with self-reported history of exercise associated muscle cramps in Ironman Triathletes: A case-control study, The Clinical Journal of Sports Medicine21(3): p204-210
Schwellnus MP, Nicol J, Laubscher R et al (2004). Serum electrolyte concentrations and hydration status are not associated with exercise associated muscle cramping in distance runners, British Journal of Sports Medicine38(4): p488-492