Are you sure that your endstop is not plugged in the wrong way around? Because this would cause a short circuit between 5V and ground, which might then destroy the 5V regulator on the Mega board...
Somehow I fear that when you switch the power supply on, the 12V get through and increase the voltage on your 5V line - may be through a broken 5V regulator. So first thing I would check the voltage of the VCC (5V) to make sure that it is correct. If it's too high you might damage your electronics...
Somehow I fear that when you switch the power supply on, the 12V get through and increase the voltage on your 5V line - may be through a broken 5V regulator. So first thing I would check the voltage of the VCC (5V) to make sure that it is correct. If it's too high you might damage your electronics...