Powering two L298N motor boards with external supply
If your second schematic correctly represents your actual wiring, the problem is that you are connecting the arduino 5V pin (instead of the GND pin) to the L298 GND.

I assume you have also connected the control pins of the motor controllers to Arduino pins?