Your function $f$ is the restriction $f := g|_{S^2}$ of a smooth function $g(x,y,z) = z$ which is defined on the whole of $\mathbb{R}^3$ to the sphere $S^2$ (which is a two-dimensional manifold). A critical point $p$ of $f$ as a function on $S^2$ need not be a critical point of $g$ (in fact, $g$ has no critical points on $\mathbb{R}^3$). For $p \in S^2$ to be a critical point, we want $df|_p = 0$ where $df|_p \colon T_{p} S^2 \rightarrow \mathbb{R}$ is defined on the tangent plane to $S^2$ (which is a subset of $\mathbb{R}^3$). Thus, a point $p \in S^2$ will be a critical point of $f$ not when all the partial derivatives of $g$ at $p$ vanish but when the differential $dg|_{p}$ sends the tangent plane $T_p{S^2}$ to zero (and it can do whatever it wants on the normal direction).
For $p = (0,0,\pm 1)$, the tangent plane to the sphere is $\operatorname{span} \{ e_1, e_2 \}$ and $dg_{p}$ sends $e_1,e_2$ to
$$dg|_{p}(e_1) = \frac{\partial g}{\partial x}(p) = 0, dg|_{p}(e_2) = \frac{\partial g}{\partial y}(p) = 0$$
so $p$ is a critical point of $f$ even though $dg|_{p}(e_3) = \frac{\partial g}{\partial z}(p) = 1 \neq 0$.