a/
\(=2\left(x^2-6x+9\right)+2y\left(x-3\right)\)
\(=2\left(x-3\right)^2+2y\left(x-3\right)\)
\(=2\left(x-3\right)\left(x-3+2y\right)\)
b/
\(=x^2-4y^2+4\left(x+2y\right)\)
\(=\left(x-2y\right)\left(x+2y\right)+4\left(x+2y\right)\)
\(=\left(x+2y\right)\left(x-2y+4\right)\)