5. Point $P$ is equidistant from point $A(1,0)$, $B(a, 2)$, and the line $x=-1$. If such a point exists and is unique, then the value of $a$ is $\qquad$

Translate the above text into English, please keep the original text's line breaks and format, and output the translation result directly.
5. $\pm 1$.

Let the coordinates of point $P$ be $P(x, y)$. Given that the distance from $P$ to $A(1,0)$ and the line $x=-1$ are equal, the locus of point $P$ is $y^{2}=4 x$.
Also, $|P A|=|P B|$, thus
$$
\sqrt{(x-1)^{2}+y^{2}}=\sqrt{(x-a)^{2}+(y-2)^{2}},
$$

which simplifies to $2(1-a) x-4 y+3+a^{2}=0$.
The problem is then converted to: the system of equations
$$
\left\{\begin{array}{l}
y^{2}=4 x, \\
2(1-a) x-4 y+3+a^{2}=0
\end{array}\right.
$$

having a unique solution.
If $a=1$, we get $y=1, x=\frac{1}{4}$, which is a unique solution.
If $a \neq 1$, eliminating $x$, we get
$$
(1-a) y^{2}-8 y+2\left(a^{2}+3\right)=0.
$$

By $\Delta=0$, we get $a^{3}-a^{2}+3 a+5=0$, which is
$$
(a+1)\left(a^{2}-2 a+5\right)=0.
$$

Therefore, $a=-1$.