The process of getting the UK out of the EU, would start immediately, but the British Prime Minister, Theresa May, announced that she would invoke Article 50 by the end of March 2017, meaning that the UK would be on course to leave the EU by the end of March 2019. Why keep these times? Can't do it right away?
The main reason is that there is a two-year timeframe for negotiations to take place once Article 50 is invoked. Theresa May's government's was just formed 3 months ago and is thus still preparing for negotiations.
The negotiations are crucial to reach an agreeable deal between the UK and the EU. The government needs time to plan out the negotiations and think of what kind of deal they want. Otherwise, they will lose all the benefits of being an EU member, notably trade deals.
During the two-year negotiation period, UK will continue to receive the benefits in the EU and continue to participate in EU activities as a normal member. However, it will not be invited to participate in discussions on the terms of the deals.
UK's government wanted to try to negotiate with other members before invoking Article 50 but the leaders of other EU nations didn't agree to that. Consequently, the President of the European Commission Jean-Claude Juncker requested all EU members not to negotiate with UK regarding Brexit until the invocation of Article 50. So, the British government had to invoke Article 50 before commencing negotiations.
With these reasons, it isn't wise to invoke Article immediately after the referendum since they have to plan out their steps carefully. Once Article 50 is triggered, the clock will start ticking and they will be officially out of the EU in two years as there is no way to untrigger it.
Two years seem long enough to negotiate a deal? It isn't.
The UK wants to get most out of the deals, especially trade deals. However, the EU needs to deter further members from leaving by showing that it isn't wise to leave. So, the negotiations would have to draw a line between these two factors.