It is possible you never trigger sleep mode if you are just closing the lid of the laptop. This could possible be due to software never letting the Mac to sleep, or it may indicate a hardware issue with the sleep sensor or Lid Angle Sensor.
What is the exact model of your Mac and version of macOS? You can get this information by clicking the Apple menu and selecting "About This Mac". FYI, you should always provide this information when asking for assistance online.
How are you triggering the laptop to lock itself? Probably would be best to try clicking "Sleep" on the Apple menu, then trying to wake the laptop. If it asks for a password, then great, but if it does not, then repeat, but this time waiting a minute, two minutes, etc.
If you have an Intel Mac, then perform an SMC Reset and a PRAM Reset (hold the PRAM Reset for at least two chimes if possible). These resets are not available on an Apple Silicon Mac.