Expand the equation on the left side and compare it with the equation on the right side:
$$ (x-a)^2 = x^2-6x+b$$
$$ x^2-2ax+a^2=x^2-6x+b$$
$$ x^2 \colorbox{yellow}{\(-2ax\)} + \colorbox{aqua}{\(a^2\)}= x^2 \colorbox{yellow}{\(-6x\)}+\colorbox{aqua}{\(b\)} $$
Comparing corresponding parts,
Linear terms
$$-2ax=-6x$$
$$a=3$$
Constant terms
$$a^2=b$$
$$3^2=b$$
$$\boxed{9}=b$$