Leg cramps at night while sleeping are mostly caused by restrictions in the blood flow while sleeping.
Sometimes nerves and blood vessels get pinched and then blood flow can be partially cut off during the night depending on how you're positioned during sleep.
Other times muscles may be strained during the day which can lead to night cramps and it's normal and usually nothing to worry about.
Exercise can also strain your muscles and cause the leg cramps at night too especially if you overdo the exercise.
However if you do notice swelling, redness or skin changes along with the leg cramps then seek medical attention just to be safe although leg cramps at night and during the day are just mostly painful and nothing serious.