I tried tackling this problem by first dividing both sides by $a$ so that I get $a^{3(n+1)^2} \equiv 1$ mod 21. I did that so I can use the Chinese remainder theorem (since gcd(3, 7) = 1) to get the equations
$x \equiv 1$ mod 3
and
$x \equiv 1$ mod 7
Then I thought of using Fermat's little theorem to proceed, but that led me nowhere.
Any help is appreciated, thanks!
As $21=3\cdot7$
Using Fermat's Little Theorem $$a^3\equiv a\pmod3\implies3|a(a^2-1)$$ $$ a^7\equiv a\pmod 7\implies7|a(a^6-1)$$
As $a^6-1=(a^2)^3-1^3=(a^2-1)\cdots$
lcm$(3,7)$ will divide $a(a^6-1)$
So it is sufficient to establish $$3(n+1)^2+1\equiv1\pmod6$$ $\iff(n+1)^2\equiv0\pmod2$
$\iff n+1\equiv0\pmod2$
$\iff n+1$ is even