Take the second pill at 30 minutes. It lasts 30 minutes.
Take the third pill at 60 minutes. It lasts 30 minutes.
Total time: 90 minutes.
Who said each pill lasts 30 minutes? You are assuming the effect of the pills lasts for 30 minutes but nowhere was that stated. The Doctor just said to take one every 30 minutes.
Once you take a pill it is gone. The three pills last 60 minutes.
You are out of pills at 60 minutes when you take the 3rd one. At 90 minutes you don’t have a pill to take.
The effects of those 3 pills would last for several more hours, depending on lots of variables.