The issue is that for $g$ to be continuous it is not enough for $f$ to be continuous at $x$. It is not even enough for $f$ to be continuous at every $y \in [x]$, for example consider $f : \mathbf{R}_{>0} \to \{0,1\}$ which takes $(n- 1/n, n + 1/n)$ to $1$ and every other point to $0$ and the equivalence $\sim$ which identifies $\mathbf{N}_{> 0} \subset \mathbf{R}_{> 0}$, ie $x \sim y$ iff $x = y$ or $x, y \in \mathbf{N}$. Then $g$ takes $[1]$ to $1$, but every neighborhood of $[1]$ contains a point where $g$ takes the value $0$.
So you need to use continuity of $f$ "uniformly" around all points of $[x]$ simultaneously, and the correct notion of "uniform" is to consider $\pi^{-1}(V)$ for neighborhoods $V$ of $[x]$.
If the quotient map $\pi$ happens to be open, for instance if $\sim$ is induced by a continuous action of a group, then it *is* enough to know that $f$ is continuous at each $y \in [x]$: take $V_y \subset f^{-1}(U)$ a neighborhood of $y$, then $\pi(\bigcup V_y)$ is a neighborhood of $[x]$ contained in $g^{-1}(U)$.