To touch externally, the distance between the centres = the sum of the radii.
So, $(a-0)^2+(a-0)^2=(|a|+2)^2$
(i)$\implies 2a^2=a^2+4|a|+4\implies a^2-4|a|-4=0$
As $a\ge0,a^2-4a-4=0, a=2\pm2\sqrt2$
As $a\ge0,a=2+2\sqrt2$
alternatively,(ii) $2a^2=(a+2)^2\implies \sqrt2a=a+2 $ as $a>0,a+2>0$ $\implies(\sqrt2-1)a=2 \implies a=\frac 2{\sqrt2-1}=2(\sqrt2 +1)$
To touch internally, the distance between the centres = the difference of the radii.
So, $(a-0)^2+(a-0)^2=(|a|-2)^2$
(i)$a^2+4|a|-4=0$
As $a>0,a^2+4a-4=0,a=-2\pm2\sqrt 2$
So, $a=2\sqrt2-2$
alternatively,(ii) $2a^2=(a-2)^2$
$\implies \sqrt2a=a-2$ if $a\ge 2$
$\implies (\sqrt2-1)a=-2\implies a=-\frac{2}{\sqrt 2-1}<0<2$ which is impossible.
$\implies \sqrt2a=2-a$ if $a< 2$
$\implies a(\sqrt2+1)=2\implies a=2(\sqrt 2-1)$