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