Experts aren’t exactly sure why some people get muscle spasms more than others. One or more of the following may be to blame in most cases: Not enough stretching. Muscle fatigue. Exercising in extreme heat (heat cramps). Dehydration. Electrolyte imbalance (having too many or too few salts and minerals like potassium, magnesium and calcium, in your body). Stress. Too much high-intensity exercise. Possible causes for nocturnal leg cramps (leg cramps at night), specifically, include: Sitting for long periods of time. Overusing your muscles. Standing or working on concrete floors. Sitting improperly.