I had a Sheltie that never had this problem and my friend raised them and never heard of back leg cramps. Although it could happen, I guess. Especially if the dog runs around quite a bit. It does sound like a seizure of some kind or maybe nerve damage somewhere. See a Vet for diagnostic testing! You don't want this to get worse and find out you could have prevented it. I am sure the dog is fearful when it is happening!
It sounds like a siezure. If this is determined by a vet, medications to control siezures can be very effective.
It may be something the breed is prone to. From personal experience, I know that Scotties are prone to back leg cramps, and it's not a medical problem. I've found with consistent exercise they're much less likely to have trouble. You might just call the vet and ask if Shelties are prone to back leg cramps. I have a suspicion this is the case, as my neighbor's Sheltie gets back leg cramps.
This does sound odd. I am not sure what could be causing this either, but she wouldn't be having these 'spells' if there wasn't something a little wrong somewhere. I would definitely get her checked out at the vet's.