Ring of order $p^2$ is commutative.

Solution 1:

Let $R$ be a ring with $p^2$ elements, let $0 \neq x \in R$, we have to show that $Z(x) = \{r \in R : xr=rx\}$ coincides with $R$. It is an additive subgroup, even a subring, contains $x$, and therefore has order $p$ or $p^2$. In the latter case we are done. Assume that it has order $p$. Every ring of order $p$ is canonically isomorphic to $\mathbb{Z}/p$. It follows that $x=z \cdot 1$ for some $z \in \mathbb{Z}$. But then obviously $Z(x)=R$.


For rings without unit, also called rngs, this fails: There are $11$ rngs with $p^2$ elements, see here. Two of these are non-commutative, namely $E=\langle a,b : pa=pb=0, a^2=a, b^2=b, ab=a, ba=b \rangle$ and $F = \langle a,b : pa=pb=0, a^2=a, b^2=b, ab=b, ba=a\rangle.$

Solution 2:

Warning: I assume here that "ring" means "unital ring", not "rng" without unity.

There is a canonical ring morphism $f:\mathbb Z\to R$ (this is true for all rings).
Its image $f(\mathbb Z)\subset R$ has cardinality either $p^2$ or $p$.
$\bullet $ In the first case $f(\mathbb Z)=R$ and since $f(\mathbb Z)= \mathbb Z/p^2\mathbb Z$ (the only quotient of $\mathbb Z$ of cardinality $p^2$) we are done: $R= \mathbb Z/p^2\mathbb Z$, a commutative ring.

$\bullet \bullet$ In the second case $f(\mathbb Z)= \mathbb Z/p\mathbb Z$ (the only quotient of $\mathbb Z$ of cardinality $p$) and $R$ is a $\mathbb Z/p\mathbb Z$-algebra.
That algebra is then generated by any element $r\in R\setminus (\mathbb Z/p\mathbb Z)$, i.e. $R=\mathbb Z/p\mathbb Z[r]$, which immediately implies that $R$ is commutative, since $f(\mathbb Z)=\mathbb Z/p\mathbb Z$ is in the center of $R$ and since powers of $r$ commute with each other.

Complement
Actually, we can classify all the rings in $\bullet \bullet$.
If $m(x)=x^2+ax+b\in \mathbb Z/p\mathbb Z[x]$ is the minimal polynomial of $r$ over $\mathbb Z/p\mathbb Z$ we then have $R=\frac{ \mathbb Z/p\mathbb Z[x]}{\langle m(x)\rangle}$ and it follows that $$R=\mathbb F_{p^2} \;\text {(the field with} p^2 \text {elements)},\;\mathbb Z/p\mathbb Z\times \mathbb Z/p\mathbb Z \;\text{or} \;(\mathbb Z/p\mathbb Z)[x]/(x^2)$$ according as $m(x)$ is irreducible, reducible with distinct roots or reducible with a double root.