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