Self balancing robot but not balance

This is far beyond your ability... consider trying a rolling "vehicle" and not a robot... but keep going until you burn out or catch up...

Both are trouble.

Verify your power supply is sufficient to supply power for the L298N as well as the motors. Many non-working "vehicle" projects start with a weak power supply.

You need to test every device in your project. Start with your L298N. Write a small sketch to make each motor go in one direction, then the other, then use PWM to change the rate of motor, then make both wheels do some movement.

Next, a small sketch with the MPU6050. See that it can register movement. Then, see that it can register and correct for stability... for the device to be stable, it needs to always be correcting itself. The MPU library (every library) has a folder full of examples. Run them and learn from them.