First notice that $-1\le\cos m!\pi x\le 1$ for all $m$ and $x$, so $0\le\cos^2m!\pi x\le 1$. Suppose that $0\le y\le 1$; then
$$\lim_{n\to\infty}y^n=\begin{cases}
0,&\text{if }y\ne 1\\
1,&\text{if }y=1\;.
\end{cases}\tag{1}$$
Now $\cos^2 m!\pi x=1$ if and only if $m!x$ is an integer. Say $m!x=a$ for some integer $a$; then $x=\frac{a}{m!}$, a rational number. Thus, $m!x$ is never an integer when $x$ is irrational, and therefore for all $m$ we have $\cos^2m!\pi x\ne 1$. $(1)$ then implies that $$\lim_{n\to\infty}\cos^{2n}m!\pi x=0$$ for all $m$, and of course in that case $$\lim_{m\to\infty}\lim_{n\to\infty}\cos^{2n}m!\pi x=\lim_{m\to\infty}0=0\;.$$
This explains why the limit is $0$ when $x$ is irrational.
If $x$ is rational, on the other hand, we can write $x=\frac{a}b$ for some integers $a,b$ with $b>0$. Then for all $m\ge b$ we can be sure that $m!x$ is an integer and hence that $\cos^2m!\pi x=1$. But then the sequence
$$\left\langle\cos^{2n}m!\pi x:n\in\Bbb N\right\rangle$$
is constantly $1$ for $m\ge b!$, so for $m\ge b!$ we have
$$\lim_{n\to\infty}\cos^{2n}m!\pi x=1\;.$$
But then the sequence $$\left\langle\lim_{n\to\infty}\cos^{2n}m!\pi x:m\in\Bbb N\right\rangle$$
is constantly $1$ for $m\ge b!$, and
$$\lim_{m\to\infty}\lim_{n\to\infty}\cos^{2n}m!\pi x=1\;.$$