How to make SMART Pedestal Fan with Blynk

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.
http://help.blynk.cc/getting-started-library-auth-token-code-examples/blynk-basics/keep-your-void-loop-clean

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-down resistor and needs to be LOW at startup…

Thirdly, if everything works correctly with no AC load attached to the high voltage side of the relays, but becomes problematic when a load is attached then you are suffering from EMF interference from your load. The only way to solve this is to put a suitably sized and properly rated capacitor across the load terminals to filter out the EMF interference.

TBH, three inputs and four outputs is pushing the limits of what you can achieve with an ESP8266. You’d be better switching to an ESP32 for this type of project, although I’m nit 100% clear why the mainSwitch is required.

Pete.