We like to think that voltage in electronics is, if not constant, then at least it’s not going above the supply voltage. So if we apply 5V at the input of the electronic device, it will never go unintentionally above 5V inside.
It is, however, not true. As soon as you add any type of inductive load (choke, coil, electric motor) things go wild. Current flowing through the inductive element does not like to be interrupted. If it does, it will produce a voltage spike that will propagate to the rest of the electronics. The voltage spike can be high enough to destroy sensitive electronics.
This, and a few other reasons, require protecting electronics from voltage spikes.
The idea is to use a Transil - Transient Voltage Suppressor, aka TVS. Modern TVS diodes are small devices that when the voltage crosses a threshold (for example 30V) start to conducts and basically, for a fraction of a second, shorts the circuit, allowing voltage spike to dissipate. As long as the voltage is above the threshold, TVS stays short. When it drops below the threshold, it closes and everything goes back to normal.
TVS should be installed in the circuit where the voltage spike is the most likely to happen. Close to the inductor that cause the spike. But it also can be installed parallel to the voltage source.
So, next time you have a voltage spike, you should check if TVS is installed in the circuit. If it’s not there, install it. If it is, you should check if it is still working. If it is not, you should replace it.