I was struggling with this issue for a while. After I updated my PC with Windows 10 to Windows 11. I used to connect to this PC remotely using RDP. Any time I disconnected from RDP the PC went to sleep.
I was not able to find anything relevant on Google.
After some more digging in Event Viewer I found some events related to GCloud a part of GService which is software provided by GIGABYTE.
After I uninstalled GService the problem finally disappeared!