I wear compression socks ALL the time, and when my legs acted this way, it wasn't the socks, but the fact I was low on potassium. I now keep bananas around the house for a quick potassium boost. See if this trick helps your condition.
The possible reason why your legs are cramping is due to the pressure from the socks. The socks are tight and this might cause blocking of the veins that disabling free circulation of blood. Try and avoid these socks and if the same thing happens the next time you wear them, it will be important to see a doctor.