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