\(3x^4y^2+3x^3y^2+3xy^2+3y^2=3x^3y^2\left(x+1\right)+3y^2\left(x+1\right)\)
\(=\left(3x^3y^2+3y^2\right)\left(x+1\right)=3y^2\left(x^3+1\right)\left(x+1\right)\)
\(=3y^2\left(x+1\right)\left(x^2-x+1\right)\left(x+1\right)=3y^2\left(x^2-x+1\right)\left(x+1\right)^2\)