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