Arduino MEGA2560 code stops after power down and up

Are you leaving the serial monitor open when you unplug and re-connect the USB cable?
If so, this behaviour is normal and you don't need to upload the code again. You only need to close and re-open the serial monitor.
You figured this bit out.

Yes, opening the serial monitor resets the Arduino. There's a "RST EN" link on the board that you can cut to stop this behaviour, but then you need to manually press RST during uploading, or fit a jumper where you cut the link.