To prevent muscle cramps, stay hydrated, maintain electrolyte balance, stretch regularly, and avoid sudden increases in intensity or duration of exercise. If you experience a muscle cramp, gently stretch and massage the affected area, and consider drinking a sports drink or consuming foods rich in potassium and magnesium to help alleviate symptoms.