If \(n\) is odd:
$$\begin{gather} n = 2k+1 \implies n^2 = 4k^2 + 4k + 1 \\ n^2 - 1 = 4k^2 + 4k \\ n^2 - 1 = 4(k)(k + 1) \end{gather}$$
Since one of \((k)(k+1)\) would be even, then:
$$\begin{gather} n^2 - 1 = 4(2q) = 8q \\ n^2 ≡ 1 \mod 8 \end{gather}$$
Now let's focus on the fact that \(3 ∤ n\), this means that at least one of these is true:
$$\begin{gather} n ≡ 1 \bmod 3 \\ n ≡ 2 \bmod 3 \end{gather}$$
Which means there exists integers \(x\) and \(y\) such that at least one of these is true:
$$\begin{gather} 3x = n - 1 \\ 3y = n - 2 \end{gather}$$
This means:
$$\begin{align} 3x +1= n &\implies n^2 = 9x^2 + 6x + 1 \implies n^2 -1 = 9x^2 + 6x \\ 3y +2=n &\implies n^2 = 9y^2 +12y + 4 \implies n^2 - 1 = 9y^2 +12y + 3 \end{align}$$
The above shows that if \((n ≡ 1 \bmod 3)\) or \((n ≡ 2 \bmod 3)\), either way \(n^2 - 1 \) would be a multiple of 3:
$$n^2 ≡ 1 \mod 3$$
If \((n^2 ≡ 1 \bmod 3)\), \((n^2 ≡ 1 \bmod 8)\) and \((3,8)=1\), then, according to this:
$$\begin{align} n^2 &≡ 1 \mod (8*3) \\ n^2 &≡ 1 \mod 24 \end{align}$$