how to prevent airplane mode from turning on when I turn off wifi?

Please run the command:

rfkill list all

You will see something like this:

0: tpacpi_bluetooth_sw: Bluetooth
Soft blocked: no
Hard blocked: no
1: phy0: Wireless LAN
Soft blocked: no
Hard blocked: no
48: hci0: Bluetooth
Soft blocked: no
Hard blocked: no

Take note of the device identifier values; in this case, 0, 1 and 48.

Toggle the bluetooth off:

sudo rfkill block 48

And on:

sudo rfkill unblock 48

Toggle the wireless off:

sudo rfkill block 1

Check:

rfkill list all

You will see something like this, depending on the make and model of your laptop:

 0: tpacpi_bluetooth_sw: Bluetooth
 soft blocked: no
 Hard blocked: no
 1: phy0: Wireless LAN
 Soft blocked: yes
 Hard blocked: no
 48: hci0: Bluetooth
 Soft blocked: no
 Hard blocked: no

The wireless is soft(ware) blocked. It will be hard(ware) blocked by the wireless switch or key combination on your laptop. The rfkill command cannot move the switch!

Toggle the wireless on:

sudo rfkill unblock 1