An associative ring $R$ is called von Neumann regular if for each $x\in R$ there exists a $y\in R$ such that $x = xyx$.
Now let $R$ be a commutative ring. Its dimension is the supremum over lengths of chains of prime ideals in $R$. So for example, fields are zero dimensional because the only prime ideal in a field is the zero ideal.
The proof follows directly from the definition: suppose $P\subset R$ is a prime ideal of a von Neumann regular ring. If $x\not\in P$ and $y\in R$ is an element such that $x = xyx$, then $x(1 – yx) = 0$. Since $x\not\in P$, we must have $1 = yx$. Therefore, $P$ is maximal.
What about the converse? That’s what this counterexample is all about.
A counterexample must be a commutative ring that is zero dimensional but not von Neumann regular. Such a ring is $\Z/p^2$ for a prime $p$. It is zero dimensional because every finite commutative ring is zero dimensional. Why is it not von Neumann regular? Consider the element $p\in \Z/p^2$. Is there an element $y\in \Z/p^2$ such that $p = pyp$? No, because the right-hand side $pyp = p^2y = 0$. In fact, slightly modified, this argument shows that a von Neumann regular ring actually has to be reduced.
An infinite counterexample
We already remarked that a von Neumann regular has to be reduced and zero-dimensional. In fact, it turns out that a commutative ring $R$ is von Neumann regular if and only if $R$ is reduced and zero dimensional. This equivalence gives us a hint on how to construct an infinite zero dimensional ring that is not von Neumann regular: take a principal ideal domain and quotient out by some power of an element to make it the quotient zero dimensional.
For example, if $k$ is any field, the ring $k[x]/x^2$ will do. It is zero dimensional (and in fact local) because its only prime ideal is $(x)$. It cannot be von Neumann regular because it is not reduced. In fact, $x$ itself is an element such that there does not exist a $y\in k[x]/x^2$ with $x = xyx$.