Recommended · for beginners
EEVblog 1409 - The DANGERS of Inductor Back EMF
Why people recommend it
Dave Jones shows the voltage spike an inductor or relay coil produces when switched off, which explains why flyback diodes are fitted across coils and motors.
Watch for: the measured spike when the relay is switched off
In their words
Don't forget about placing the flyback diode (EEV Blog, Wiki) in reverse polarity, parallel to the magnet.
gbg on arduino.stackexchange.com, Aug 2021. CC BY-SA.
This video by Dave from the EEVBlog explains what happens when you apply a voltage to an inductor (relay) and then suddenly break the connection: back EMF: [video] Sure, Dave powers a relay but that's also an inductor so the same thing happens in your circuit.
Bimpelrekkie on electronics.stackexchange.com, Oct 2021. CC BY-SA.
There's an interesting video on back EMF which may highlight why diodes are used.
Mark N Hopgood on electronics.stackexchange.com, Jul 2021. CC BY-SA.