<s>[INST] Find all values of $a$ for which the system of equations it has exactly two solutions 
Find all values $a$ for which the system of equations it has exactly two solutions
  $$\begin{cases}
x^2-8x+y^2-8(|x|+|y|-2)=4;
\\
y=ax-4a-6
\end{cases}$$

My attempt:
1) $$x^2-8x+y^2-8(|x|+|y|-2)=4$$

2) $\forall a \in \mathbb R$ $$(4;-6) \in y=ax-4a-6$$
 [/INST] As you wrote, $L:y=ax-4a-6$ is a line passing through $P(4,-6)$. 
For $x\lt 0$, we have
$$x^2-8x+y^2-8(-x+|y|-2)=4\iff x^2+(|y|-4)^2=4$$
For $x\ge 0$, we have
$$x^2-8x+y^2-8(x+|y|-2)=4\iff (x-8)^2+(|y|-4)^2=68$$
These are the parts of four circles 
$$C_1 : x^2+(y-4)^2=4\ \ (x\lt 0,y\ge 0),\quad C_2 : x^2+(y+4)^2=4\ \ (x\lt 0,y\lt 0)$$
$$C_3 : (x-8)^2+(y-4)^2=68\ \ (x\ge 0,y\ge 0),\quad C_4 : (x-8)^2+(y+4)^2=68\ \ (x\ge 0,y\lt 0)$$
$\qquad\qquad$


*

*$C_1$ and $C_3$ intersect at $A(0,2)$ and $B(0,6)$.

*$C_3$ and $C_4$ intersect at $C(8-2\sqrt{13},0)$ and $D(8+2\sqrt{13},0)$.

*$C_2$ and $C_4$ intersect at $E(0,-2)$ and $F(0,-6)$.

*The line $L:y=ax-4a-6$ is tangent to $C_1$ at $G$ when $a=\frac{-10+2\sqrt 7}{3}$.

*The slope of the line $l$ passing through $P,F$ is $0$.

*The slope of the line $g$ passing through $P,D$ is $\frac{\sqrt{13}-2}{3}$.

*The slope of the line $h$ passing through $P,B$ is $-3$.

*The slope of the line $i$ passing through $P,A$ is $-2$.

*The slope of the line $j$ passing through $P,C$ is $\frac{-2-\sqrt{13}}{3}$.

*The slope of the line $n$ passing $P,G$ is $\frac{-10+2\sqrt 7}{3}$.

*The slope of the line $k$ passing through $P,E$ is $-1$.
We see that for $-2\le a\lt\frac{-10+2\sqrt 7}{3}$, the line $L$ and $C_1$ has two intersection points, so these $a$ have to be eliminated.
Also, for $a=\frac{-10+2\sqrt 7}{3}$, there are three intersection points, so this $a$ has to be eliminated.
Therefore, the answer is
$$\color{red}{a\lt -2\quad\text{or}\quad a\gt \frac{-10+2\sqrt 7}{3}}$$
</s>