Conjecture: When $n \gt 2$ is an even number, $n\pm 1$ is a twin prime pair iff there exists a nontrivial solution of $X^{(n-2)n} = 1 \pmod {n^2 - 1}$.
Proof:
To see this suppose $n \pm 1 \in \Bbb{Z}$ are twin primes. Then by Euler's totient theorem $X^{n-2} = 1 \pmod {n-1}$ and $X^{n} = 1 \pmod {n+1}$. So that by the Chinese Remainder theorem those two equations multiply into $X^{(n-2)n} = 1 \pmod {n^2 -1}$.
Conversely, suppose that the even number $n \gt 2$ is such that a solution $X$ exists to the equation $X^{n(n-2)} = 1 \pmod {n^2-1}$.
Since $n$ is even $n \pm 1$ must be a coprime pair of integers: Fixing the coprime error. $d | n \pm 1 \implies n-1 = n+1 \pmod d \implies -1 = 1 \implies d = 2$ but $n$ is even, so $dx = n + 1 \implies 1 = 0 \pmod 2$. Done.
Since $n \pm 1$ are coprime now, we can use the reverse isomorphism from the Chinese Remainder Theorem and break into two equations: $X^{(n-2)n} = 1 \pmod {n\pm 1}$.
We feel the need to appeal to Euler's totient function. We know that the multiplicative group of the ring $\Bbb{Z}/(m)$ must have order $\phi(m)$ and that there is a formula for it: $\phi(m) = m \prod_{p |m}p^{e-1}(1 - 1/p)$ where $e$ in the formula is the max exponent of the prime $p$ dividing $m$.
Let $m = n^2 -1$. And $R = \Bbb{Z}/(m)$. Clearly $\phi(m) = |R^{\times}| \lt |R|$. Since in our smaller rings $X^{n(n-2)} = 1$, we have that
Apparently this conjecture is false. See below.
Let $n=14$. Then $(n-2)n=12\cdot 14=168$, and $n^2-1=14^2-1=195$. Take $X=2$. Then $$2^{168}\equiv1\bmod{195}.$$ But $n-1=13$, while $n+1=15$, and 15 is clearly not prime. Your statement seems to be incorrect.
What I expect to be the correct statement:
For an even number $n$, the pair (n-1,n+1) is a twin prime pair if and only if $(\Bbb Z/(n^2-1)\Bbb Z)^\times$ has $(n-2)n$ elements.
In this case the first part of your proof works out. For the second part we can use that $\varphi(n^2-1)=(n-2)n$, from which follows that $\varphi(n-1)=n-2$ and $\varphi(n+1)=n$. This shows that they are prime.