That happens when you get disconnected. If you are disconnected, you won't be aware of your opponent's last move and your opponent's clock will (apparently) continue to count down, leading to the situation you described, where you think you are waiting and that your opponent has run out of time.
You should try refreshing your page to make sure you are connected in such situations.
How to solve the problem when the time of the opponent went to zero, but it freezes and I lost in a better position and plenty of time?