Division is defined the same way in modular arithmetic as it is on the regular number line. In other words, $\frac12$ is the unique number such that $2\cdot \frac12 = 1$. However, since modular arithmetic works differently from regular arithmetic, the interpretation of the above definition is very different: We have $2\cdot 3 = 1$, which means that $3$ actually fulfills the defining property of $\frac12$. We can also easily check that there are no other such numbers, so it is unique. That is why $\frac12 = 3$.
Note for later: If you ever have to solve quadratic equations in modular arithmetic (at least as long as it's modulo an odd prime), the formula $\frac{-b \pm \sqrt{b^2 - 4ac}}{2a}$ still works, except once again, the definition of $\sqrt{{}\cdot{}}$ is the same (sortof; there isn't anything like positive / negative to distinguish the two square roots of a number), but the interpretation is different, with, for instance, $\sqrt{-1} = \pm 2$ modulo $5$.