To factor $ x^2-2x-a^2x+2a^2 $ we can use factoring by grouping.
Group $ \color{blue}{ x^2 }$ with $ \color{blue}{ -2x }$ and $ \color{red}{ -a^2x }$ with $ \color{red}{ 2a^2 }$ then factor each group.
$$ \begin{aligned} x^2-2x-a^2x+2a^2 &= ( \color{blue}{ x^2-2x } ) + ( \color{red}{ -a^2x+2a^2 }) = \\ &= \color{blue}{ x( x-2 )} \color{red}{ -a^2( x-2 ) } = \\ &= (x-a^2)(x-2) \end{aligned} $$