You can make it easier by replacing x^n with another variable, factoring, then putting x^n back in the end.
Using exponent and algebra rules, rewrite x^2n - 2x^n + 1 as
(x^n)^2 - (2 x x^2) + 1
Then, let x^n = m.
m^2 - 2m + 1
Now factor that: (m - 1)^2
And now put x^n back: (x^n - 1)^2