While electrolyte imbalances can cause this, it's not likely unless you are doing endurance rides on this horse so looking for other causes is important.
What you are seeing is commonly referred to as "tying up" and can have different causes as well as having other conditions that look like it but aren't "tying up". The first thing you need to do is to have some blood drawn within 12 hours of an attack and have your vet run some chemistries to determine if there is muscle damage occuring. Then you start looking at WHY it is occuring. If your current vet isn't an "equine vet", I would find one that is who can see your horse.
Here is a good article:
The Horse: AAEP Convention 2006: Muscle Disorders