Let $R$ be a ring with unity and $|R|= p^2,$ where $p$ is prime. Let $I$ be a principal ideal of $R$ generated by some $x.$ If $|I|=p^2$ then $I=R$ so if $(R,+) \cong \mathbb{Z}/p \oplus \mathbb{Z}/p$ then we get a contradiction since $\mathbb{Z}/p \oplus \mathbb{Z}/p$ does not contain such an $I.$ So $R\cong \mathbb{Z}/p^2$ so there exists $x\in R$ such that every element of is of the form $k.x$ for some $1\leq k\leq p^2$ and hence the product of any $2$ elements will commute as a result of being finite sums of $x.$
Hence every principal ideal must have order $p.$ Let $x,y\in R$ be arbitrary, $x \neq 1, 0$ and let $I_1, I_2$ be the principal ideal generated by $x$ and $y$ respectively. Then both $(I_1, +)$ and $(I_2, +)$ are cyclic of order $p$ and hence can be written as $I_1 = \{0,a, \ldots (p-1).a\}$ and $I_2=\{0,b, \ldots (p-1).b\}.$ By definition of an ideal, $ab, ba \in I_1\cap I_2 = \{0\}$ it follows that $ab =ba=0.$
Since $I_1+I_2$ is an ideal of size $|I_1|. |I_2|/|I_1\cap I_2| = p^2$ we have $R= I_1+I_2.$ Then for any $c, d \in R$ we have $c = m_1.a +n_1.b$ and $d=m_2.a +n_2.b$ so that $cd = (m_1m_2).a + (n_1n_2).b =dc$ and hence $R$ is commutative.