There are two possibilities.
A faulty lid angle sensor. When you close the lid of the laptop, does the display go dark just before the lid is completely closed? And when you lift the display open about a 1/4", do you see the display turn on again? If so, then the Lid Angle Sensor is probably Ok (not a guarantee, but most likely it is Ok).
Otherwise you most likely have an issue with some third party software, or a configuration issue of some sort. You can run the third party app EtreCheck and post the complete report here so we can examine it for possible clues.
How to use the Add Text Feature When Posting an EtreCheck Report - Apple Community
Unfortunately when putting a Mac to sleep does not mean it stays asleep the whole time. Different macOS system processes and cloud syncing, etc. will wake the Mac up from time to time in order to perform various maintenance functions. It can be difficult trying to figure out what is causing the Mac to wake up.
You can run the following Terminal command to see the sleep/wake reasons and it will also report the battery charge level at the time although the reasons may be a bit cryptic. I'm providing the command to show the events for Friday & Saturday (8/15 & 8/16) so you can get the information during the night when the date changes (adjust the dates accordingly for the time you want to review).
pmset -g log | grep -iE 'Sleep |Wake ' | grep -iE '^2025-08-15|^2025-08-16'
It is best to just copy & paste this command since any typographical error will result in unexpected behavior or even failure. To adjust the date, just use the left arrow key to move the cursor so you can use the "Delete" key to delete the digit(s) and type in the digits for the date you want. Press the "Return" key to submit the command so it can be executed.
You can also use this modified version which will save the output to a text file located on your Desktop called "Sleep-Wake-log.txt". If you run the command more than once on the same date, then it will just append another copy of the data to this same file (there is no reason to run it more than once a day).
pmset -g log | grep -iE 'Sleep |Wake ' | grep -iE '^2025-08-15|^2025-08-16' >> "$HOME"/Desktop/Sleep-Wake-log.txt