/e/ stuck in "andriod is starting" screen

Its my first time on here, please be gentle.
So I am using a Samsung Galaxy S8, ive flashed the software personally, and the bug i incountered is that after i left my phone to charge over night it somehow restarted and when i wanted to turn it on, the power button would not do anything, so the screen would only turn on if i put it back on charge, and when it did turn on, past the lock screen, it said “Android is starting” like it got reset or something, and soon after that the screen would go black and become unresponsive for about 10 seconds before charging it would turn it back on, the battery gauge was also completly wrong saying there was 0% battery while it had 81% acording to my quick settings opening. So I manadged to exit this loop by going into download mode and exiting it (which will reboot the phone), and this problem was gone with it. Can someone tell me what happened, and why?

Regain your privacy! Adopt /e/ the unGoogled mobile OS and online servicesphone