The Apollo3 processor has six I2C/SPI high-speed Master Modules (IOM).
On an Nano :
IOM0 is used for SPI communication (pins 11, 12,13),
IOM2 is used for I2C/Wire/QWIIC
IOM3 is used for I2C1/ Wire1 (pin 6 and 7).
You could still assign IOM1, IOM4 and IOM5. However the output of each IOM can only be assigned to certain pads. A pad is a connection to the processor and a pin is a connection on the side of the board. In the case of Nano, not all pads are connected to a pin. Thus you can not use IOM1 (pads are not connected) and not use IOM5 (the UART is connected there). In case of a Nano you can only use IOM4, but you have to define the correct pads / pins. You can NOT use 17 and 18.
Either set :
#define mySDA D10 // use pin definition
#define mySCL D9
or
#define mySDA 40 // use pad definition
#define mySCL 39