Line 2 is correct because of the distribution rule. You multiply each outer term by the inner terms in the parenthesis.
2x(4x+8) = 2x*4x + 2x*8 = 8x^2+16x
-3*(4x+8) = -3*4x-3*8 = -12x-24
---------------------------------------------------------------------------------------------
Line 3 is correct as well. The 16x and -12x combine to 4x. You can think of it like 16-12 = 4, then just tack x's onto everything getting 16x-12x = 4x
Or you can think of it like "16 boxes - 12 boxes = 4 boxes" and you replace "boxes" with "x" for shorthand.
The other terms aren't like terms so we just leave them as is.