Why isn't $x^2+x+1$ a factor of $x^{12}+x^6+1$?

You are correct that if all of the roots of a polynomial $f(x)$ are roots of a polynomial $g(x)$, then $f(x)$ is a factor of $g(x)$.

However $x^2 + x + 1$ is not a factor of $x^{12} + x^6 + 1$. The reason is because $- \frac{1}{2} \pm i \frac{\sqrt{3}}{2}$ are not roots of that polynomial. This is because

$$ \left( - \frac{1}{2} \pm i \frac{\sqrt{3}}{2} \right)^3 = 1,$$

so plugging it into $x^{12} + x^6 + 1$ gives $(x^3)^4 + (x^3)^2 + 1 = 1 + 1 + 1 = 3 \neq 0$.


I'm sorry, but I don't know how you arrived at your assertion that $-1/2 \pm i \sqrt{3}/2$ are roots of $x^{12} + x^6 + 1$. In fact, we note $$-\frac{1}{2} \pm i \frac{\sqrt{3}}{2} = e^{\pm 2\pi i/3},$$ hence $$(e^{\pm 2\pi i/3})^{12} + (e^{\pm 2\pi i/3})^6 + 1 = 1 + 1 + 1 = 3 \ne 0.$$


@AnginaSeng has already proved dividing $p(x):=x^{12}+x^6+1$ by $x^2+x+1$ leaves a remainder of $3$.

In thinking the remainder would be $0$, you seem to have misindentified the roots of $p$. Since $x^6=\exp\frac{\pm2\pi i}{3}$, $x=\exp\frac{\pm\pi i}{9}\exp\frac{n\pi i}{3}$ for $n\in\{0,\,1,\,2,\,3,\,4,\,5\}$. You can verify, e.g. by working modulo $\frac{\pi i}{9}$, that none of these $12$ roots' phases matches either root of $x^2+x+1$, which would be $\exp\frac{\pm 2\pi i}{3}=\exp\frac{\pm6\pi i}{9}$.