Here's a direct proof. Let $x\in f^{-1}(U)$. By definition, there exists $y\in U$ so that $f(x)=y$. Since $U$ is open and that $y\in U$, there exists $\epsilon>0$ such that $B_{\epsilon}(y)\subset U$. By continuity of $f$, there exists $\delta>0$ such that $x'\in B_{\delta}(x)$ implies $f(x')\in B_{\epsilon}(y)$. Hence $B_{\delta}(x)\subset f^{-1}(U)$, i.e. there is an open ball of radius $\delta>0$ centered at $x$ completely contained in $f^{-1}(U)$. Since $x\in f^{-1}(U)$ was arbitrary, $f^{-1}(U)$ is open. $\boxed{}$
Edit: Here is a proof by contradiction. Suppose for contradiction that $f^{-1}(U)$ is not open. Then there exists $x\in f^{-1}(U)$ such that $B_{\delta}(x)\not\subset f^{-1}(U)$ for any $\delta>0$. On the other hand, $U$ is open, so there exists $\epsilon>0$ so that $B_{\epsilon}(f(x))\subset U$, then... (the ideas are similar to the direct proof, I will leave it to you to write a proof).