I will try to answer your question for the case of order $p^2$, where $p$ is a prime, and for unitary commutative rings $R$.
Note first that we have a unique homomorphism $f:\mathbb{Z}\to R$, sending $1$ to $1$.
If the image of $f$ is $R$, then $R\cong \mathbb{Z}/\ker(f)$, hence $R\cong \mathbb{Z}/p^2\mathbb{Z}$ as rings.
If the image is not $R$, it must have order $p$, hence $$\mathbb{F}_p:=\mathbb{Z}/p\mathbb{Z} \hookrightarrow R$$
which makes $R$ an $\mathbb{F}_p$-vector space, necessarily of dimension $2$.
If $R$ is a field, then, by a general theorem on existence and unicity of finite fields of order $p^n$, then $R\cong \mathbb{F}_{p^2}$, the unique field of order $p^2$.
If $R$ is an integral domain, since any finite domain is a field , we are reduced to the previous case.
If $R$ is not an integral domain, either there exists $a\ne b\in R$, $a\ne 0 \ne b$, such that $a\cdot b=0$, or there exists $a\in R$, $a\ne 0$, such that $a^2=0$.
Consider first the second case: then, consider the morfism of rings $g:\mathbb{F_p}[x]\to R$ sending $p(x)$ to $p(a)$. Clearly $g(\mathbb{F_p}[x])= R$, since $\langle 1,a\rangle _{\mathbb{F}_p} =R$ already as vector spaces (since $a\notin \mathbb{F}_p$), and $\ker(x)\supset (x^2)$. But $\mathbb{F_p}[x]/(x^2)$ has $p^2$ elements, hence $R\cong \mathbb{F_p}[x]/(x^2)$.
We are left with the case that there exists $a\ne b\in R$, $a\ne 0 \ne b$, such that $a\cdot b=0$, but $c^2\ne 0$ for all $c\in R$, $c\ne 0$. We will see that $R\cong \mathbb{F_p}\times \mathbb{F}_p$. The idea is that $\langle a, b\rangle _{\mathbb{F}_p} =R$, since they are both linearly independent over $\mathbb{F}_p$: if $a=n\cdot b$, $n\in \mathbb{F}_p$, $n\ne 0$, then $0=a\cdot b=n\cdot a^2$, hence $a^2=0$, which we suppose is not true. Now, there exists $n,m\in \mathbb{F}_p$, $n\ne 0 \ne m$, such that $1=na+mb$. After changing $a$ and $b$ for $na$ and $mb$, we can suppose $a+b=1$. But then
$a^2=a(1-b)=a-ab=a$, and similarly for $b$. One cheks that the bijection $\psi: \mathbb{F_p}\times \mathbb{F}_p\to R$ sending $\psi(i,j)=i\cdot a+j\cdot b$ is a morphism of rings, so an isomorphism.
Hence, there are $4$ unitary commutative rings with $p^2$ elements:
$$ \mathbb{Z}/p^2\mathbb{Z},\ \mathbb{F}_{p^2},\ \mathbb{F_p}\times \mathbb{F}_p \text{ and } \mathbb{F_p}[x]/(x^2).$$
p.s. After writting this answer I learn that all unitary rings of order $p^2$ are commutative. So previous argument covers all unitary rings.