Find the equation of the circle that touches these three lines $x= 0$, $y=0$, $x = a$. 
Find the equation of the circle that touches these three lines $x= 0$, $y=0$, $x = a$.

Here is my attempt:
$x = 0$ and $y = 0$, these both line go through the $x$ and $y$ axes. And also the circle touches those two lines. So the center will be $C(p,p)$. That means $r = k = h = p$. The circle also touches the $x = a$ line. That means $r = a/2$. From that, I determined the center as $C(a/2, a/2)$.
The equation:
$$\left(x - \frac{a}{2}\right)^2 + \left(y - \frac{a}{2}\right)^2 = \left(\frac{a}{2}\right)^2$$
$$x^2 + y^2 - 2ax - 2ay + \frac{a^2}{4} = 0$$
which is not the correct answer. 

Now can anyone tell me what's wrong with this attempt? 


Your error is very simple: you have wronged expanding the square, in fact $\left(x - \frac{a}{2}\right)^2 + \left(y - \frac{a}{2}\right)^2 = \left(\frac{a}{2}\right)^2$ is not $x^2 + y^2 - 2ax - 2ay + \frac{a^2}{4} = 0$, but: $$x^2-ax+\frac{a^2}{4}+y^2+ay=0$$ In other words: $$4x^2+4y^2-4ax-4ay+a^2=0$$
Also, by simmetry, I get $\left(x - \frac{a}{2}\right)^2 + \left(y + \frac{a}{2}\right)^2 = \left(\frac{a}{2}\right)^2$: $$4x^2+4y^2-4ax+4ay+a^2=0$$
To clarify, see this graph where $a=6$:

