This always seems to happen to me during the most useless meetings.
But yeah, it's actually very easy to misjudge periods of time, because when we estimate how long it has been, we are actually comparing real time to a more nebulous parameter like our awareness of events passing. Sometimes the events passing are even just in our own mind, and time seems to take a very long time. People in isolation and cut off from external stimuli typically end up with radically stretched estimates of how much time has passed. When you focus on a clock, you tend to automatically calibrate to it, so you won't experience this when you are focusing on it.
In your first experience, the fact that you were thinking about something very complicated is why you had the temporal experience. You were measuring the passage of time relative to how many things you thought, and in the midst of your complicated thought, you probably had several thoughts pass in parallel, which your brain sorted into a longer sequence of thoughts. Thus, you perceived more "time" passing in one clock tick, which was actually just more thoughts happening.
The seasonal master of time dilation -->