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
[tex]\displaystyle \lim_{x\to2} f(x)[/tex]
must exist.
From the left side, we have x < 2 and f(x) = x², so
[tex]\displaystyle \lim_{x\to2^-} f(x) = \lim_{x\to2} x^2 = 4[/tex]
From the right, we have x > 2 and f(x) = mx + b, so
[tex]\displaystyle \lim_{x\to2^+} f(x) = \lim_{x\to2} (mx+b) = 4m+b[/tex]
It follows that 4m + b = 4.
Differentiability means that the limit
[tex]\displaystyle \lim_{x\to2} \frac{f(x) - f(2)}{x - 2}[/tex]
must exist.
From the left side, we again have x < 2 and f(x) = x². Then
[tex]\displaystyle \lim_{x\to2^-}\frac{f(x)-f(2)}{x-2} = \lim_{x\to2} \frac{x^2-4}{x-2} = \lim_{x\to2} (x+2) = 4[/tex]
From the right side side, we have x > 2 so f(x) = mx + b. Then
[tex]\displaystyle \lim_{x\to2^+}\frac{f(x)-f(2)}{x-2} = \lim_{x\to2} \frac{(mx+b)-(2m+b)}{x-2} = \lim_{x\to2} \frac{mx-2m}{x-2} = \lim_{x\to2}m = m[/tex]
The one-sided limits must be equal, so m = 4, and from the other constraint it follows that 16 + b = 4, or b = -12.