If the keyboard is still lit, then it implies the laptop is still powered on. If you play music does the music continue playing when this happens or does the music stop playing? I have had a few Macs where the video on the screen will freeze, but the Mac will continue to run. I have never been able to figure these issues out and has occurred on different hardware and versions of macOS. I do know that other users have had this issue as I have described ever since macOS 10.6 and usually attribute the issue to a GPU issue or GPU driver.
Run the Apple Diagnostics to see if any hardware issues are detected. Unfortunately the diagnostics do not detect many hard drive failures so you can run DriveDx to check the health of the hard drive. To look for possible software issues run EtreCheck.
Post both the DriveDx and EtreCheck reports here using the "Additional Text" icon which looks like a piece of paper.
Of course if you performed a true clean install by first erasing the whole physical drive before installing macOS and you thoroughly tested the clean install before migrating or restoring from a backup and before installing any third party apps, then you really don't need to run EtreCheck since you should not have had any third party apps or custom settings enabled.
Does the issue occur when using the charger?
Have you tried disconnecting all external devices in case one of them is causing a problem?