Nice problem .
1)$ n = 2k + 1$ then if $ a_{n} = x^{2}$ we have :
$ x^{2}\equiv 2^{n} (modp)$ because $ p|a$ , $ \longrightarrow x^{2}\equiv 2.(2^{k})^{2}(modp)$ , but $ (2,p) = 1$ so we can multiply $ (2^{*})^{2k}$ to both side . so we have $ y^{2}\equiv 2(modp)$ which gives $ p\equiv \pm 1 (mod8)$ and it's a contradiction .
2)$ n = 2k$ then we must have $ 2^{2k} + a = x^{2}$ and then $ a = (x - 2^{k})(x + 2^{k})$ . but $ a$ is a fix integer and it has only finitely divisors , so there is only finitely $ k$ which $ a_{n}$ is perfect square .