Now, bearing in mind that, for a graph, to be "differentiable", means a "smooth transition", not an abrupt edge or a "cusp", the first subfunction of the piece-wise is just a quadratic, the second subfunction is a linear, well, so the linear needs to hit the quadratic "smoothly", not make an abrupt edge, for that, the linear must continue the quadratic from 2 onwards, since 2 is the range edge.
now, what is the piece-wise when x = 2? well, f(2) = x² or (2)² or 4
that means, the linear needs to hit it at that point, to make it so, let's make it the slope of the linear, the same as the quadratic's.
what's the quadratic's slope? well, simple enough
so we have y = 4x + b
now, recall, for the quadratic, when x =2, y = 4, so for the linear, when x = 2, y = 4 as well, this means
check the picture below.