How do I prevent my MacBook Pro from dimming the screen on battery power?
Have you tried turning off auto-brightness on your Mac? That could be why it keeps adjusting the brightness by itself after a while (i.e., its ambient sensor thinks your display should be a different brightness and changes accordingly)

Here's a tutorial on how to turn auto-brightness off: https://www.techjunkie.com/disable-auto-brightness-mac/

I hope that helps!