8. Find all positive integers $a$ such that for any positive integer $n \geqslant 5$, we have $\left(2^{n}-n^{2}\right) \mid\left(a^{n}-n^{a}\right)$.
8. Solution 1 If $2^{a}-a^{2} \neq 0$, then take a prime number
$$
p>\max \left\{\left|2^{a}-a^{2}\right|, 2\right\} \text {, and }(p, a)=1 \text {, }
$$

and take a positive integer $n=p(p-1)+2$.
Since $p \geqslant 3$, therefore, $n \geqslant 8>5$.
By Fermat's Little Theorem, we have
$$
\begin{array}{l}
2^{n}-n^{2} \equiv 2^{2}\left(2^{p-1}\right)^{p}-[p(p-1)+2]^{2} \\
\equiv 2^{2} \times 1-2^{2} \equiv 0(\bmod p) . \\
\text { Thus, } p \mid\left(a^{n}-n^{a}\right) . \\
\text { And } a^{n}-n^{a} \equiv a^{2}\left(a^{p-1}\right)^{p}-[p(p-1)+2]^{a} \\
\equiv a^{2} \times 1-2^{a}(\bmod p), \\
\text { hence } p \mid\left(2^{a}-a^{2}\right) . \\
\text { But } p>\left|2^{a}-a^{2}\right| \text {, and } 2^{a}-a^{2} \neq 0, \text { which contradicts } p \mid\left(2^{a}-a^{2}\right)
\end{array}
$$

Therefore, $2^{a}-a^{2}=0$.
When $a \leqslant 4$, it is clear that only $a=2,4$ satisfy the equation.
When $a \geqslant 5$,
$2^{a}=(1+1)^{a}$
$>1+a+\frac{a(a-1)}{2}+\frac{a(a-1)(a-2)}{6}$
$>a+\frac{a(a-1)}{2}+\frac{3 a(a-1)}{6}=a^{2}$.
So, the positive integer $a$ that satisfies the condition can only be $2$ or $4$.
When $a=2$, it clearly satisfies the condition;
When $a=4$,
$$
4^{n}-n^{4}=\left(2^{n}-n^{2}\right)\left(2^{n}+n^{2}\right)
$$

also satisfies the condition.
In summary, the values of the positive integer $a$ are $2$ and $4$.
Solution 2 The values of the positive integer $a$ are 2, 4.
First, verify that when $a=2$ or 4, the conditions of the problem are satisfied (same as Solution 1).
Next, prove: Only 2 and 4 satisfy the conditions.
(1) Prove: $a$ is even.
In fact, take $n$ to be any even number greater than 5. Since $2^{n}-n^{2}$ is even, $a^{n}-n^{a}$ is also even. Therefore, $a$ is even.
(2) Prove: $a$ has no odd prime factors.
Assume $a$ has an odd prime factor $p$.
When $p=3$, take $n=8$, then $2^{n}-n^{2}=192$ is a multiple of 3, but at this time $a^{n}-n^{a}$ is not a multiple of 3, which contradicts the problem statement.

When $p=5$, take $n=16$, then $2^{n}-n^{2}=65280$ is a multiple of 5, but at this time $a^{n}-n^{a}$ is not a multiple of 5, which contradicts the problem statement.
When $p \geqslant 7$, take $n=p-1$. By Fermat's Little Theorem, $2^{p-1} \equiv 1(\bmod p)$.
Note that, $(p-1)^{2} \equiv 1(\bmod p)$.
Thus, $p \mid\left(2^{n}-n^{2}\right)$.
By $(p-1)^{a} \equiv(-1)^{a} \equiv 1(\bmod p)$ and $p \mid a^{n}$, we know $p \nmid\left(a^{n}-n^{a}\right)$, which contradicts the problem statement.
(3) Prove: The value of the positive integer $a$ is 2, 4.
From (1) and (2), we can set $a=2^{t}\left(t \in \mathbf{N}_{+}\right)$.
Then, by $\left(2^{n}-n^{2}\right) \mid\left(2^{1 n}-n^{2}\right)$ and
$\left(2^{n}-n^{2}\right) \mid\left(2^{\text {tn }}-n^{2 t}\right)$,

we get $\left(2^{n}-n^{2}\right) \mid\left(n^{2 t}-n^{2 t}\right)$.
At this time, take a sufficiently large $n$.
By $\lim _{n \rightarrow \infty} \frac{n^{2^{t}}}{2^{n}}=0$, we know $n^{2^{t}}-n^{2 t}=0$.
Thus, $2^{t}=2 t$.
When $t=1,2$, it satisfies the condition;
When $t \geqslant 3$, by the binomial theorem, we know
$$
t=2^{t-1}=(1+1)^{t-1}>1+(t-1)=t \text {, }
$$

which is impossible.
In summary, the values of the positive integer $a$ are 2, 4.