How can I set the default editor as nano on my Mac?

Set the EDITOR and VISUAL environment variables to nano.

If you use bash on macOS, this is easiest done by editing your ~/.bash_profile file and adding the two lines

export EDITOR=nano
export VISUAL="$EDITOR"

to the bottom of the file. If the file does not exist, you may create it.

You should set both variables as some tools use one and others may use the other.

You will need to restart your terminal to have the changes take effect.