Both x² and mx + b are differentiable functions of x (they are both polynomials), so if f(x) is also differentiable, we need to pay special attention at x = 2 where the two pieces of f meet.
Continuity means that the limit

must exist.
From the left side, we have x < 2 and f(x) = x², so

From the right, we have x > 2 and f(x) = mx + b, so

It follows that 4m + b = 4.
Differentiability means that the limit

must exist.
From the left side, we again have x < 2 and f(x) = x². Then

From the right side side, we have x > 2 so f(x) = mx + b. Then

The one-sided limits must be equal, so m = 4, and from the other constraint it follows that 16 + b = 4, or b = -12.