The exponent applies only to teh term it is next to. In this case, it applies to teh binomial in teh parentheses.
3(x+2)2 - 2(x+1)
3(x+2)(x+2) - 2(x+1)
FOIL the (x+2)(x+2) and distribute the -2:
3(x2 + 2x + 2x + 4) - 2x - 2
Distribute the 3:
3x2 + 6x + 6x + 12 - 2x - 2
Combine like terms
3x2 + 10x + 10