So sorry for you loss. This must have been a horrible experience to endure. Honestly, this is quite a rare occurrence. In the several years working for the vet we never had a single case of a dog dying from a spay (a spay is considered a routine surgery), but I do hear that it occasionally happens.
Did she die on the surgical table or at home during the recovery? If on the table, this could have been an anesthesia complication and sometimes there may have been a congenital abnormality such as a malformed heart or an issue with the kidneys which prevented the anesthesia to be cleared as quickly and effectively as it should have.
Sometimes, there may be an aneurysm or a arrhythmia taking place in the heart. Excessive bleeding leading to death may also take place if there is a blood clotting problem. Problems for this can happen both on the surgical table or at home during recovery.
If this is troubling you, you can have a necropsy done so to see whether there was an underlying problem that went undetected.
As for things to do to prevent this in the future, there may be not much really if this was an unfortunate isolated event. If there was a congenital issue at play perhaps not buying from the same breeder may help. Also, having the vet run bloodwork prior to the surgery can help too so to identify any prominent issues with organs which may go undetected.
Again, so sorry for your loss.