If the relay board has a JD-VCC jumper in place then you are almost certainly bypassing the optoisolators on your relay board.
Even so, you may need to add a suitably capacitor across your relay terminals.
A bit more reading for you…
The first thing you need to do is to sort-out your void loop - it’s an absolute mess!
You need to either user a timer to poll your physical switches, or attach interrupts to them and use debounce code.
Secondly, I’d advise you to either switch from using “D” pin designations to using GPIO numbers, or at the very least add a note in the comments about which GPIO each pin relates to.
Pulling GPIO15 (D8 - used for speed_3_switch) HIGH with a resistor is a bad move. It has a built-in pull-dow…
What type of load are you switching?
If it’s something that generates electrical noise - a motor, fan, bell, buzzer etc. - then it’s probably EMF that’s flowing back into your Arduino.
In this case the solution is usually a suitably rated capacitor across the relay terminals.
Pete.
Pete.