I think it calculates your sleep based how you interact with your phone, so assuming you don't touch your phone again after 5pm till the following day the app assumes you fell asleep at 5pm.
It's just an app, there's only so much it can determine
Sent from my Redmi K20 Pro using Tapatalk