ESP-32 not working with big motor
Inductive kickback and other noise may be making its way to the ESP32, and confuse or even damage it. For a DC motor that turns one way you need a big diode (in reverse, so it doesn't conduct normally) across the motor, and maybe a small capacitor too. See Purpose of the diode and capacitor in this motor circuit, for instance.
For a DC motor that turns both ways like yours, where to put the diode(s) depends on your switching arrangement, see the answer to How to use a flyback diode on a +/-12V motor, or you could use a bidirectional TVS diode, as they are known.
A capacitor of 100nF sounds about OK, there's more to read here: http://pololu.com/docs/0J15/9
As for the P6KE13CA you mention: it has a Vrwm of only 11.1V, and a minimum breakdown voltage of 12.4V, which is a bit tight when using a 12V battery/motor; it will leak a bit, probably no biggie, but I would try finding one with a Vrwm of at least 14v
Also check if the power supply can deliver enough current to drive the motor; if it struggles, voltage will drop and you may suffer a &quot;brown-out&quot;.