PC goes into sleep mode and all programs are closed.

Hello,
Have a problem with my operating system and that is, sometimes when I start any programs, the PC goes to sleep mode by itself and have to enter my password again. It’s like restart. If I did anything and did not save, it goes away.

Can someone please help me with this?
Thanks