How to calculate $|\operatorname {SL}_2(\mathbb Z/N\mathbb Z)|$? the answer should be
$$|\operatorname {SL}_2(\mathbb Z/N\mathbb Z)|=N^{3}\prod_{p|N}(1-{1 /p^2})$$
But first how to prove
$$|\operatorname {SL}_2(\mathbb Z/p^e\mathbb Z)|=p^{3e}(1-{1 /p^2})$$
 A: The formula is the multiplication of several simpler ones, specialized to $n=2$.


*

*$SL_n(\mathbb{Z}/N \mathbb{Z}) = \prod SL_n(\mathbb{Z}/p^e \mathbb{Z})$.  From the Chinese Remainder Theorem.

*$|SL_n(\mathbb{Z}/p^e \mathbb{Z})| = p^{(n^2-1)(e-1)}|SL_n(\mathbb{Z}/p \mathbb{Z})|$.  From smoothness and ($n^2-1$)-dimensionality of $SL_n$, in any characteristic.

*$|SL_n| = |GL_n|/(q - 1)$ over a finite field of cardinality $q$. From the bijection between invertible elements and cosets of $GL / SL$.

*$|GL_n(\mathbb{F}_q)| = (q^n-1)(q^n-q) \dots (q^n - q^{n-1})$. "Well known".


The main point is the unobstructed Hensel lifting (step 2), which manifests the smoothness of $SL$ in every characteristic.
A: Here is how I tackled this when I was given it as a homework problem:
We prove that $\def\SL{\text{SL}}$ $\def\Z{\mathbb{Z}}$ $\def\GL{\text{GL}}$
$$|\SL_2(\Z/p^e\Z)|=p^{3e}\left(1-\frac{1}{p^2}\right)$$
by induction.
For the base case, $e=1$, note that we have the exact sequence
$$1\to\SL_2(\Z/p\Z)\to\GL_2(\Z/p\Z)\xrightarrow{\det}(\Z/p\Z)^\times\to 1$$
and thus, 
$$|\SL_2(\Z/p\Z)|=\frac{|\GL_2(\Z/p\Z)|}{p-1}$$
But, it is a common exercise (just count the number of distinct ordered bases) that $|\GL_2(\Z/p\Z)|=(p^2-1)(p^2-p)$, and thus 
$$|\SL_2(\Z/p\Z)|=\frac{(p^2-1)(p^2-p)}{p-1}=(p+1)(p^2-p)=p^3\left(1-\frac{1}{p^2}\right)$$
as desired. 
Now, suppose that we have proven that $\displaystyle |\SL_2(\Z/p^e\Z)|=p^{3e}\left(1-\frac{1}{p^2}\right)$. Note that we have the obvious projection map $\Z/p^{e+1}\Z\to\Z/p^e\Z$ given by reduction modulo $p$. Because this is a ring map, this induces a homomorphism $f:\SL_2(\Z/p^{e+1}\Z)\to\SL_2(\Z/p^e\Z)$. Let us now compute the cardinality of $\ker f$. 
We begin by noting that $\begin{pmatrix}a & b\\ c & d\end{pmatrix}\in\SL_2(\Z/p^{e+1}\Z)\in\ker f$ if and only if 
$$\begin{pmatrix}a & b\\ c & d\end{pmatrix}\equiv \begin{pmatrix}1 & 0\\ 0 & 1\end{pmatrix}\mod p^e$$
So, let us count the number of such matrices in $\SL_2(\Z/p^{e+1}\Z)$ that satisfy this. In other words, we are really looking for the number of distinct matrices in $\SL_2(\Z/p^{e+1}\Z)$ of the following form:
$$\begin{pmatrix}mp^e+1 & \ell p^e\\ kp^e & np^e+1\end{pmatrix}\tag{$\bf1$}$$
Note that this matrix, a priori only in $\text{Mat}(\mathbb{Z}/p^{e+1}\Z)$ is in $\SL_2(\mathbb{Z}/p^{e+1}\Z)$ if and only if its derterminant
$$(mp^e+1)(np^e+1)-\ell k p^{2e}\equiv p^e(m+n)+1\mod p^{e+1}$$
is actually equivalent to $1$ modulo $p^{e+1}$. Thus, we need 
$$p^e(m+n)+1\equiv 1 \mod p^{e+1}$$
to hold, which says that $p\mid m+n$. Thus, the only requirement to make a matrix of the form $\mathbf{(1)}$, the candidates to be in $\ker f$, to be in $\SL_2(\Z/p^{e+1}\Z)$ is that $p\mid m+n$ and $k,\ell$ can be arbitrary.
Thus, we need to see really how many distinct matrices are of the form $\mathbf{(1)}$ as $m,n,k,\ell$ roll over the possible values in $\mathbb{Z}$. Well, up to equivalence it's easy to see that the number of distinct pairs $(m p^e,np^e)$ in $(\mathbb{Z}/p^{e+1})^2$ such that $p\mid m+n$ is $p$. This just follows by the obvious fact that such $m,n$ are only determined modulo $p$, and that such pairs are then in one-to-one correspondence with the kernel of the obviously surjective map 
$$(\Z/p^2\Z)^2\to\Z/p\Z:(x,y)\mapsto x+y$$
and thus there are $\displaystyle \frac{p^2}{p}$ choices. Since the elements $\ell,k$ are arbitrary, but are only determined modulo $p$, it follows that there are $p^2$ choices between them. Thus, the total number of distinct matrices of the form $\mathbf{(1)}$ in $\SL_2(\Z/p^{e+1}\Z)$ is $p^3$. 
We may then conclude from the first isomorphism theorem that:
$$|\SL_2(\Z/p^{e+1}\Z)|=|\ker f||\SL_2(\Z/p^{e}\Z)|=p^3 p^{3e}\left(1-\frac{1}{p^2}\right)=p^{3(e+1)}\left(1-\frac{1}{p^2}\right)$$
and thus the induction is complete.

From this we can deduce that 
$$|\SL_2(\Z/N\Z)|=N^3\prod_{p\mid N}\left(1-\frac{1}{p^2}\right)$$
as follows. The ring isomorphism 
$$\Z/N\Z\cong \prod_{p\mid N}\Z/p^{e_p}\Z$$
coming from the CRT gives rise to a group isomorphism
$$\SL_2(\Z/N\Z)\cong\prod_{p\mid N}\SL_2(\Z/p^{e_p}\Z)$$
Thus,
$$\begin{aligned}|\SL_2(\Z/N\Z)| &= \prod_{p\mid N}|\SL_2(\Z/p^{e_p}\Z)|\\ &= \prod_{p\mid N}p^{3e_p}\left(1-\frac{1}{p^2}\right)\\ &= \left(\prod_{p\mid N} p^{e_p}\right)^3\prod_{p\mid N}\left(1-\frac{1}{p^2}\right)\\ &= N^3\prod_{p\mid N}\left(1-\frac{1}{p^2}\right)\end{aligned}$$

EDIT: I don't know why this is of interest to you, but you can easily deduce from this $[\SL_2(\Z):\Gamma(N)]$, where 
$$\Gamma(N)=\left\{\begin{pmatrix}a & b\\ c & d\end{pmatrix}\in\SL_2(\Z):\begin{pmatrix}a & b\\ c & d\end{pmatrix}\equiv \begin{pmatrix}1 & 0\\ 0 & 1\end{pmatrix}\right\}$$
That is because there is an exact sequence
$$1\to \Gamma(N)\to\SL_2(\Z)\to\SL_2(\Z/N\Z)\to 1$$
(the surjectivity of the last map (which is just reduction modulo $N$) is a little trick, the proof can be found here). This is important because $\Gamma(N)$ is the so-called "principle congruence subgroup" of $\SL_2(\Z)$ and is the object of fundamental importance in classical modular forms.
