It happens. Hopefully less often as you get more experience under your belt. You take a quick look at a task on a project and based on previous experience with “similar” tasks, you give what you think is a fairly accurate estimate of how much time and effort it will take. And then you start into the task. Two hours in and you start rethinking that estimate because you’re learning that the task/project/problem is a bit more complex than you originally believed. The key here is not to freak out and try to rush and finish the task – that generally never ends well. The best option is to communicate – inform and educate the stakeholders on whats happening and provide a new estimate based on the reality of what you’re experiencing. Communicate early and often, but don’t overdo it or your communication will just become noise (or worse). This will help everyone stay on the same page.
And next time, your estimate will be even more accurate (and reality-based) because of this experience.