Calculating $\mathbb{E}X^2$ When we could use the following equation:
$$\mathbb{E}X^2=\int_0^\infty 2t \mathbb{P}(X>t)$$ I mean how is it possible to change $X^2$ to $2t$?

Assuming $X$ is nonnegative, the trick is to (1) put $x^2=\int_0^x2t\,dt$ in the formula for $\mathbb E(X^2)$, obtaining a double integral, and then (2) interchange the order of integration. Writing $f(x)$ for the density of $X$, the derivation goes:
$$
\begin{align}
\mathbb E(X^2)&=\int_{x=0}^\infty x^2f(x)\,dx\\
&\stackrel{(1)}=\int_{x=0}^\infty\left(\int_{t=0}^x2t\,dt\right)f(x)\,dx\\
&=\int_{x=0}^\infty\left(\int_{t=0}^x2tf(x)\,dt\right)\,dx\\
&\stackrel{(2)}=\int_{t=0}^\infty\left(\int_{x=t}^\infty2tf(x)\,dx\right)\,dt\\
&=\int_{t=0}^\infty 2t\left(\int_{x=t}^\infty f(x)\,dx\right)\,dt\\
&=\int_{t=0}^\infty 2t\,\mathbb P(X>t)\,dt\\
\end{align}
$$
