1) \(2a\left(x+2\right)+a^2\left(-x-2\right)\)
\(=2a\left(x+2\right)-a^2\left(x+2\right)\)
\(=\left(x+2\right)\left(2a-a^2\right)\)
\(=\left(x+2\right).a.\left(2-a\right)\)
2) \(2a^2b\left(x+y\right)-2a^3b\left(-x-y\right)\)
\(=2a^2b\left(x+y\right)+2a^3b\left(x+y\right)\)
\(=\left(x+y\right)\left(2a^2b+2a^3b\right)\)
\(=\left(x+y\right).2a^2b.\left(1+a\right)\)