6. Let the prime $p$ satisfy that there exist positive integers $x, y$ such that
$$
p-1=2 x^{2}, p^{2}-1=2 y^{2} \text {. }
$$

Then the number of primes $p$ that satisfy the condition is ( ).
(A) 1
(B) 2
(C) 3
(D) 4
6. A.

Obviously, $p \neq 2$.
When the prime $p \geqslant 3$, obviously,
$$
p>y>x,
$$

and $p(p-1)=2(y+x)(y-x)$.
From $p \mid 2(y+x)(y-x)$, we know $p \mid(y+x)$.
Then $p \leqslant x+y<2 p \Rightarrow p=x+y$
$$
\begin{array}{l}
\Rightarrow p-1=2(y-x) \Rightarrow p=4 x-1 \\
\Rightarrow 4 x-1-1=2 x^{2} \Rightarrow x=1 \Rightarrow p=3 .
\end{array}
$$

Upon verification, $p=3$ meets the conditions.