Hello and welcome to Apple Support Communities Ek628,
I see that you're being logged out of your Mac after being logged in and this continues to repeat. I understand your concern, and I'd be happy to help.
You mentioned that a restart is only a temporary fix. That was a good place to start. Next, let's have you start in safe mode and test to see if the issue remains. The article below will guide you through starting in safe mode, if needed.
Use safe mode to isolate issues with your Mac
You might also want to check how your Mac is configured. This could be a reason that you're being prompted in sign in. Also, are you the only one that has access to your Mac?
If the Login window unexpectedly appears on your Mac
Let me know how it goes using safe mode. I look forward to hearing back from you.