ESP32 grilled with simple MOSFET switch for 12V water pump
I crudely overlaid the two photos you showed to get a better picture of the overall wiring.

The transistor appears to be wired correctly. You've got the gate being pulled to ground, driven by a GPIO pin. The drain goes out to your load. The source goes to ground.
The most likely cause of failure is that you mixed up the red wires and connected the red wire at the top of the photo to 12V instead of the one at the bottom.  The one at the top is connected to the 3.3V pin of the board. This bypasses the AMS1117-3.3 regulator, so you'd have fed 12V directly into the MCU. When you fed it with 5V you probably just about got away with overvolting the ESP32, without it catching fire. 12V is far too much, though.
Another potential issue is that your path to ground for the load is through the dev board. If your pump pulls quite a high current this may be excessive for the board's pins. A header pin is only rated for about 4A, so if your pump pulls more than that you're likely to cause overheating problems. You'd be better of directly wiring the source pin to ground on the terminal block.
Additionally, looking at the schematic of the NodeMCU-32S, the USB to TTL converter IC is powered directly from VDDUSB. There is a schottky diode from VDDUSB to VDD5V, so that the board will power on from USB power:

If the schottky diode that was used on your board was not in fact a 1N5819, but instead a diode with a lower reverse breakdown voltage, it is possible that feeding 12V to VDD5V caused VDDUSB to be raised to 12V, frying the TTL chip. This could then have shorted 12V into the U0TX/U0RX pins of the ESP32.