One knows that x^4+x^2+1=(x^2-x+1)(x^2+x+1) by multiplying out the right side! But I suspect that was not your question. Your question really is "how does one factor x^4+ x^2+ 1 if you do NOT know that factorization in advance?"
Notice that there are no ODD powers of x in the expression. Replace "x^2" by "y" so that you have the quadratic y^2+ y+ 1. Rewrite that as (y^2+ 2y+ 1)- y= (y+1)^2- y so that the first is a "perfect square". Think of it as the "difference of two squares" so that it can be factored as [itex][(y+1)- \sqrt{y}][(y+ 1)+ \sqrt{y}][/itex]. One wouldn't normally do that because of the [itex]\sqrt{y}[/itex] but since y= x^2, [itex]\sqrt{y}= x[/itex] and we have [(x^2+1)-x][(x^2+1)+x]= (x^2-x+1)(x^2+x+1).