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