Solution 1:

Not necessarily. Note that

$$a^{x \text{ mod }n} \text{mod }n \equiv a^x \text{mod } n$$ implies that

$$a^n \text{ mod n}\equiv 1$$,

which by Fermat's Little Theorem is wrong in infinitely many cases, as if n is prime,

$$a^n \text{ mod n} \equiv a^{n-1}$$ which is almost never true. An example of this is $a=2,n=7,x=8$, resulting in

$$2 \text{ mod 7} \equiv 2^8 \text{ mod 7}\equiv 4$$

Which clearly isn't true