10. Given a sequence $\left\{a_{n}\right\}$ with all terms being positive integers, it satisfies: for any positive integers $m, k$ there are $a_{m^{2}}=a_{m}^{2}$ and $a_{m^{2}+k^{2}}=$ $a_{m} a_{k}$, find the general term formula of the sequence $\left\{a_{n}\right\}$.
Using the identity $\left(a^{2}-b^{2}\right)^{2}+(2 a b)^{2}=\left(a^{2}+b^{2}\right)^{2}$, we get $\left(m^{2}-1\right)^{2}+(2 m)^{2}=\left(m^{2}+1\right)^{2}$, $\left[(m+1)^{2}-m^{2}\right]^{2}+[2 m(m+1)]^{2}=\left[(m+1)^{2}+m^{2}\right]^{2}$. Combining the conditions, we have $a_{\left(m^{2}+1\right)^{2}}=a_{m^{2}-1} a_{2 m}=a_{m^{2}+1}^{2}, a_{\left[(m+1)^{2}+m^{2}\right]^{2}}=a_{2 m+1} a_{2 m(m+1)}=a_{(m+1)^{2}+m^{2}}^{2}$. Below, we use mathematical induction to prove $a_{n}=1$.
When $n=1$, $a_{1}=a_{1}^{2}$, and $a_{n} \in \mathbf{N}^{*}$, then $a_{1}=1$, the conclusion holds; when $n=2$, $a_{2}=a_{1+1}=a_{1} \cdot a_{1}=1$, the conclusion holds;
Assume the conclusion holds for $n<k(k \geqslant 3)$, if $k=2 m, a_{\left(m^{2}+1\right)^{2}}=a_{m^{2}-1} a_{2 m}=a_{m^{2}+1}^{2}$ $=\left(a_{m} \cdot a_{1}\right)^{2}=1$, and $a_{n} \in \mathbf{N}^{*}$, then $a_{m^{2}-1}=a_{2 m}=1$;
If $k=2 m+1, \quad a_{\left[(m+1)^{2}+m^{2}\right]^{2}}=a_{2 m+1} a_{2 m(m+1)}=a_{(m+1)^{2}+m^{2}}^{2}=\left(a_{m+1} \cdot a_{m}\right)^{2}=1$, and $a_{n} \in \mathbf{N}^{*}$, then $a_{2 m+1}=a_{2 m(m+1)}=1$, thus the conclusion also holds for $n=k$.
In summary, by the principle of induction, for any $n \in \mathbf{N}^{*}$, we have $a_{n}=1$.