Show that f is measurable function.
First, plot the function and slice the plan for every relevant value of $\alpha$ (it will appear evident, once you plotted the function).
It takes a bit of practice, but you then compute the inverse image for every relevant value of $\alpha$, and find:
$\mathbb{R}(f<\alpha)=\left\{\begin{array}{lllll} \left[-\infty,\alpha-5\right[ & \quad\text{if }\alpha <0\\\left[-\infty,-5\right]\cup\{0\} & \quad\text{if }\alpha=0\\\left[-\infty,\alpha-5\right]\cup\left[0,\sqrt{\alpha}\right] & \quad\text{if } 0<\alpha<2\\\left[-\infty,\alpha-5\right]\cup \left[-1,\sqrt{\alpha}\right] & \quad\text{if } 2\leq\alpha<4\\\left[-\infty,\sqrt{\alpha}\right] & \quad\text{if } 4\leq\alpha\end{array}\right.$
Every set of the right is measurable, so the function $f$ is measurable.
Let $a$ be a real number, and $B=\{x\in\mathbb R : f(x)<a\}$.
Let $I_1=(-\infty,-1)$, $I_2=[-1,0)$ and $I_3=[0,+\infty)$ and $B_k=B\cap I_k$ for $k\in\{1,2,3\}$.
$B$ is the (disjoint) union of the $B_k$ subsets.
Then $x$ is in $B_1$ iff $x\in I_1$ and $x+5<a$, i.e. $x\in(-\infty,a-5)\cap I_1$.
Hence, $B_1=(-\infty,a-5)\cap I_1$ is a measurable set since it's the intersection of two intervals.
Now to $B_2$ : $x$ is in $B_2$ iff $x\in I_2$ and $a=2$.
So $B_2=I_2$ if $a=2$ and $B_2=\emptyset$ if $a\neq 2$. It's a measurable set in both cases.
And finally, $x$ is in $B_3$ iff $x\in I_3$ and $x^2<a$.
So $B_3=I_3\cap (-\sqrt{a},\sqrt{a})$ if $a>0$ and $B_3=\emptyset$ if $a\leqslant 0$. Again, it's a measurable set in both cases.
Finally, $B$ is measurable as a (finite) union of measurable sets.
IMO, the easiest way to deal with such questions is to write
$$f(x)=(x+5)\chi_{(-\infty,-1)}+2\chi_{[-1,0)}+x^2\chi_{[0,+\infty)}$$
- Intervals are measurable, hence each $\chi_I$ is a measurable function.
- Polynomial functions are continuous hence measurable.
- Sums and products of measurable functions are measurable.
Hence $f$ is measurable.