Not able to power motor with the L298N motor driver
The PP3 9V batteries you use are only suitable for loads that pull very small currents; they are nowhere near powerful enough to supply your motors (unless your motors are really tiny and pull currents in the low mA range). When connected, the 9V battery's voltage will drop immediately, and it will last only a very short time.
This is made even worse by the use of an L298N motor driver: these are very inefficient and will drop the voltage across the motors also by about 1.4V - 1.8V.
You need a proper power supply that can supply the current the motors need. If you need 9V for the motors, even 6 1.5V AAs in series would be better than using a puny 9V battery.
A more modern and efficient motor driver would be nice also, but won't solve this problem as it is caused mainly by the battery choice.