4. Determine all values of the real parameter \( a \) for which the system of equations

$$
\begin{aligned}
(x+y)^{2} & =12 \\
x^{2}+y^{2} & =2(a+1)
\end{aligned}
$$

has exactly two solutions.
4. First solution. Notice that if $(x, y)$ is a solution of the observed system, then the pairs $(-x,-y)$, $(y, x)$, and $(-y,-x)$ are also solutions. Since the system must have exactly two solutions, some of these pairs must be equal. In the case $(x, y)=(-x,-y)$, we get $x=y=0$, which is clearly not a solution. In the case $(x, y)=(-y,-x)$, we get $x=-y$, i.e., $x+y=0$, and clearly this is not a solution either. Therefore, only $(x, y)=(y, x)$ remains, i.e., $x=y$. Then the first equation reduces to $(2 x)^{2}=12$, i.e., $x= \pm \sqrt{3}(=y)$, and from the second equation we get $2(a+1)=2 x^{2}=6$, i.e., $a=2$. Thus, the only such value of the parameter $a$ is $a=2$, and then the system has solutions $(x, y) \in\{(\sqrt{3}, \sqrt{3}),(-\sqrt{3},-\sqrt{3})\}$.

Second solution. By subtracting the second equation from the first, we get $2 x y=10-2 a$. In the case $a=5$, it would follow that $x=0$ or $y=0$, and by substituting this into the first equation, we would get 4 solutions: $(x, y) \in\{(0,2 \sqrt{3}),(0,-2 \sqrt{3}),(2 \sqrt{3}, 0),(-2 \sqrt{3}, 0)\}$. Therefore, the value $a=5$ does not work for us. We further assume $a \neq 5$. Then we can express $y=\frac{5-a}{x}$. Substituting this into the second equation, we get $x^{2}+\left(\frac{5-a}{x}\right)^{2}=2(a+1)$, i.e., $x^{4}-2(a+1) x^{2}+25-10 a+a^{2}=0$. Introduce the substitution $x^{2}=t$. For the previous equation to have exactly two solutions for $x$, the equation after the substitution: $t^{2}-2(a+1) t+25-10 a+a^{2}=0$ must have exactly one solution $t$, which means its discriminant must be 0. The discriminant is $4(a+1)^{2}-100+40 a-4 a^{2}=48 a-96$, so it is equal to zero only for $a=2$. Then we have $t=\frac{2(a+1)}{2}=3$ and from there $x= \pm \sqrt{t}= \pm \sqrt{3}$, and then $y=\frac{3}{x}= \pm \sqrt{3}$. Thus, the only such value of the parameter $a$ is $a=2$, and then the system has solutions $(x, y) \in\{(\sqrt{3}, \sqrt{3}),(-\sqrt{3},-\sqrt{3})\}$.