Most likely: the RGB LEDs are active-low, so you must set the pins to OUTPUT and write HIGH to turn them off. Leaving them unconfigured or writing LOW keeps them on.
Check your board's pin numbers (Nano 33 BLE: R=22/G=23/B=24; Nano 33 IoT: R=25/26/27) — classic Nano (328P) has no on-board RGB.