Proving that $\frac{\pi ^2}{p}\neq \sum_{n=1}^{\infty }\frac{1}{a_{n}^2}$ we have many formula for $\pi ^2$ as follow $$\frac{\pi ^2}{6}=\frac{1}{1^2}+\frac{1}{2^2}+\frac{1}{3^2}....$$
and $$\frac{\pi ^2}{8}=\frac{1}{1^2}+\frac{1}{3^2}+\frac{1}{5^2}....$$ and for $\frac{\pi ^2}{9}$, $\frac{\pi ^2}{12}$, $\frac{\pi ^2}{16}$,$\frac{\pi ^2}{24}$.. and so on. If you see the number in denominator is not prime.Now we want to prove that
  $$\frac{\pi ^2}{p}\neq \sum_{n=1}^{\infty }\frac{1}{a_{n}^2}$$ Where $p$ is a prime number and $a_{n}$ a positive integer number

If you don't want to put any restrictions on the $a_n$, there is no number theory here, only analysis. If I may quote from my previous answer:

Theorem: Let $\sum_k s_k$ be a convergent sum of positive numbers, say $S=\sum_k s_k$. Suppose that, for all $n$, we have $s_n < \sum_{k=n+1}^\infty s_k$. Then there is a subsequence of $s_k$ whose sum converges to $x$ for any positive $x < S$.

Intuitively, say we're trying to construct a subsequence. The sum is convergent, so its terms must become arbitrarily small and thus allow us to approach $x$ arbitrarily closely. The only thing that can go wrong is that at some point all the  terms we have left aren't big enough to get us to $x$. The condition $s_n < \sum_{k=n+1}^\infty s_k$ ensures that, whenever this happens, we'll have room to use the earlier term $s_n$ without exceeding $x$, and so the only way we can't get to $x$ is if we were already using all the earlier terms (i.e., $x>S$).
The series $\sum_{k=2}^\infty \frac{1}{n^2}$ satisfies the hypotheses of this theorem, and so we can write any number less than $\sum_{k=2}^\infty \frac{1}{n^2}=\frac{\pi^2}{6}-1$ as a sum of the reciprocals of distinct squares (with $a_1>1$). Similarly, if $1 < x < \frac{\pi^2}{6}$, we can write $x-1$ as a sum of the reciprocals of distinct squares, and then throw in a $1$ at the beginning to get such a representation for $x$ (with $a_1=1$).
In particular, if $p$ is prime, $\frac{\pi^2}{p}$ can be written in the form you want unless $p \in \{2,3,5,11,13\}$. But that has nothing to do with their primality: it's all about the gross size of $\frac{\pi^2}{p}$.
The interesting number theory happens when you put further conditions on the $a_n$, such as requiring them to be in arithmetic progression...
