For the non-prime numbers $n$ up to $20$ I listed the number of units of $\mathbb{Z}/n\mathbb{Z}$, the number of square roots of unity of $\mathbb{Z}/n\mathbb{Z}$ and the number of divisors of $n$.
\begin{array}{c|c|c} \# & \text{units} & \text{square roots of unity} & \text{divisors} \\ \hline 4 & 2 & 2&3\\ \hline 6 & 2 & 2&4\\ \hline 8 & 4 &4 &4\\ \hline 9 & 6 & 2&3\\ \hline 10 & 4 & 2&4\\ \hline 12 & 4 & 4&6\\ \hline 14 & 6 & 2&4\\ \hline 15 & 8 & 4&4\\ \hline 16 & 8 & 4&5\\ \hline 18 & 6 & 2&6\\ \hline 20 & 8 & 4&6\\ \hline \end{array}
The number of units is just $\varphi(n)$ (Euler's totient function), i.e. the number of numbers $m < n$ that are relatively prime to $n$.
But I don't see the correlation pattern between the numbers: How do the numbers of units, square roots of unity and divisors relate for general $n$?
Or more generally: Are there expressions for the number of square roots of unity and for the number of divisors (like for the number of units = $\varphi(n)$)?

In ${\Bbb Z}_n$, $n\geq 2$, the number of units plus the number of zero divisors is $n-1$, where $0$ is not considered as a zero divisor. The reason is that for each $0\ne a\in{\Bbb Z}_n$, if $\gcd(a,n)=1$, then $a$ is a unit; otherwise, $a$ is a zero divisor.