Rewrite $ c^2-9d^2 $ as:
$$ \color{blue}{ c^2-9d^2 = (c)^2 - (3d)^2 } $$Now we can apply the difference of squares formula.
$$ I^2 - II^2 = (I - II)(I + II) $$After putting $ I = c $ and $ II = 3d $ , we have:
$$ c^2-9d^2 = (c)^2 - (3d)^2 = ( c-3d ) ( c+3d ) $$