It is much easier to help if you attach the images to your Post. See this Image Guide
Is any of your images a wiring schematic? if not please make a pencil drawing showing how you have everything connected and post a photo of the drawing.
It seems you have the 5volt supply output from the motor driver connected to V-in of the Mega.
V-in is the input of the onboard 5volt regulator of the Mega.
The V-in pin needs at least 6.5volt for the regulator to make a stable 5volt for the MCU.
If you have a reliable 5volt from the motor driver, connect it to the 5volt pin of the Mega, not to V-in.
But then again, Fritzing pictures are rarely an accurate representation of the actual build.
Leo..
Firstly don't try to power an Arduino from a motor supply, its fraught with issues.
Power the Arduino over USB or similar, power the motor supply to the 298 from your battery pack.
The logic supply to the 298 can be the 5V of your Arduino, but then never power the Arduino
without the motor supply present or you'll pull large current from the Arduino internally
in the L298, which is bad. (There's an internal path for current that is not intended to be
used like this - power up motor supply first, then logic supply, power down in reverse sequence).
Measure the supply voltages, make sure they are correct. Try with one motor first, check
both channels of the L298. Measure the current taken, make sure you're not overloading
the L298.
Never power anything up without double-checking all connections - this is a common
beginners error - you need to methodically check everything because a careless error can
easily lead to problems or damaged components, which is very annoying, but avoidable
if you are careful.
If you have access to a bench supply with adjustable current limit, this is great, it means
you can test a circuit with the current limited, often protecting against damage if something
is wrong.