I am just posting the existing proofs but in more details.
$\DeclareMathOperator{\Z}{\mathbb Z}$
$\textbf{Proof by isomorphism}\tag*{}$
Let $p$ be a prime number and $(R,+,\cdot)$ be a ring of order $p^2$ with identity.
We note that $(R,+)$ is abelian. By fundamental theorem of abelian groups, there are only two ways to express an abelian group of order $p^2$ as product of cyclic groups. (Cases 1 and 2).
$\\$
$\mathbf{Case\ 1: } \ (R,+)\cong \Z_p\times \Z_p\tag*{}$
$\Z_p\times \Z_p$ is generated by two elements of order $p$.
$\begin{align}\Z_p\times \Z_p&=\langle (1,0), (0,1)\rangle\\ &=\{m(1,0)+n(0,1) : m,n\in \Z\}\end{align}$
By isomorphism, $(R,+)$ can also be generated by two elements of order $p$.
By Lagrange's theorem, $\text{ord}(1_R)=p$. (Since $1_R\neq 0_R$, it is clear that $\text{ord}(1_R)\neq 1$. The group is not cyclic so it does not have an element of order $p^2$. This leaves the factor $p$.)
If we choose one of our generators to be $1_R$, there exists another element $x\in R$ such that $(R,+)=\langle 1_R, x\rangle$.
Thus, any element $r\in R$ can be written in the form $(m\cdot 1_R+n\cdot x)$ where $m,n\in\Z$.
Pick $r_1=m_1\cdot 1_R + n_1\cdot x$ and $r_2=m_2\cdot 1_R + n_2\cdot x$ from $R$.
Show that $r_1r_2=r_2r_1$.
$\mathbf{Case\ 2: } \ (R,+)\cong \Z_{p^2}\tag*{}$
It is cyclic so it has an additive generator $x\in R$ so that $R=\{n\cdot x: n\in \Z\}$.
Every element is of the form $n\cdot x$.
Pick $r_1=n_1\cdot x$ and $r_2=n_2\cdot x$. Show that $r_1r_2=r_2r_1$.
Lemma: If the additive group $(R,+)$ is cyclic, the ring R is commutative.
Conclusion: A ring with identity of order $p^2$ is commutative.
A ring without identity of order $p^2$ may or may not be commutative.
Example: This ring of matrices over the field $\Z_p$.
$\left\{\begin{pmatrix}a&b\\ 0& 0\end{pmatrix}: a,b\in \Z_p\right\}\tag*{}$ is a non-commutative ring of order $p^2$. It does not have an identity.
$\textbf{Proof by considering the centre}\tag*{}$
Let $p$ be a prime number and $(R,+,\cdot)$ be a ring of order $p^2$ with identity.
The center $Z(R)$ is subring of $R$ which is also an additive subgroup.
Clearly, $0_R,1_R\in Z(R)$ so by Lagrange’s theorem, $|Z(R)|=p$ or $p^2$.
If $|Z(R)|=p^2$, we are done.
If $|Z(R)|=p$, consider the quotient group $R/Z(R)$ under coset addition operation.
$\displaystyle |R/Z(R)|=\frac{|R|}{|Z(R)|}=\frac{p^2}{p}=p\tag*{}$
Thus, $R/Z(R)$ is cyclic group under coset addition. Let $r\in R$ such that $r+Z(R)$ is the generator of $R/Z(R)$.
Every coset in $R/Z(R)$ is of the form $n\left(r+Z(R)\right)=nr+Z(R)\tag*{}$ for some integer $n\in \Z$.
Pick any $x\in R$ then $x$ must be present in one of the cosets.
Let $x\in mr+Z(R)$ for some integer $m$.
$\implies x=mr+c$ for some $c\in Z(R)$.
Pick another element $y\in R$ then
$y=nr+c'$ for some $c'\in Z(R)$ and $n\in\Z$.
Now show that $xy=yx$ using the fact that $c,c'\in Z(R)$.
Note that, in this proof, we used the fact that $1_R$ exists and it does not equal $0_R$ so that $|Z(R)|\geq 2$.