If you read the comments in the example you linked to then you’ll see that it is designed to be used with a variety of different boards, some of which (like the Mega) have multiple hardware UARTs, others (Uno, Nano etc) have only one.
Where only one hardware UART is available, a second one needs to be emulated using the SoftwareSerial library.
In either case, the ESP-01 needs to be attached to it’s own UART (whether that be a hardware or software emulated one) so that the debug data and AT commands don’t get mixed-up.
Pins 0 and 1 on the Nano are the one hardware UART and are used for serial debugging, as they are also connected to the onboard USB connector.
You need to emulate a second UART using SoftwareSerial, define which pins this will use (not 0 and 1), connect your ESP-01 to these and use this dummy port (EspSerial in the example) as your connection port. For that port to be initialised, it needs top have a Serial.begin entry in void setup, and you’ve currently commented that out.
If all of this seems very messy then you’re correct. This messiness is caused by you choosing a non-IoT device with one hardware UART for an IoT project, and therefore needing to add IoT connectivity via the ESP-01.
The best overall solution is to consign the Nano and the ESP-01 to the bin and use an IoT device for your project…
Pete.