Feel sorry about the trouble that you have met on your device. From my experience, you can give resetting the SMC a shot. If this trouble still hovers, resetting NVRAM is also recommended. Beyond the login items may be the cause also, you can then boot into safe mode and disable login items.
For the steps to reset SMC, please visit the article from iBoysoft: What Is SMC & How to Reset the SMC on Intel/M1 Mac
To reset NVRAM, please read this post: NVRAM/PRAM: How to Reset & When Should You Use It on Mac
Safe Mode is a mode that blocks any interrupting apps but leaves the necessary ones to run your device normally. You can boot into it to test if the trouble still happens. If the trouble reappears, you need to remove login items to resolve startup problems on your Mac.
Step 1: On your Mac, choose Apple menu > System Settings, click General in the sidebar, then click Login Items on the right. (You may need to scroll down.)
Step 2: Make a list of the login items in the Open at Login list—you'll need to remember them later.
Step 3: Select all of the login items, then click the Remove button.
Step 4: Choose the Apple menu > Restart.
Step 5: If this solves the problem, open Login Items settings again, add the login items one at a time, and restart your Mac after adding each one.
When the problem occurs again, follow the steps above to remove only the last login item you added.
On top of all that, bring your device to the nearest Apple store for professional solutions. Take care~