There are many possible arguments. We give two that are often useful.
$1.$ The derivative $f'(q)$ is positive for $q\lt \frac{Q}{2}$ and negative for $q\gt \frac{Q}{2}$. So the function $f(q)$ is increasing up to $q=\frac{Q}{2}$, then decreasing.
It follows that $f(q)$ reaches an absolute maximum at $q=\frac{Q}{2}$.
$2.$ If $Q=0$ the result is obvious, so assume $Q\ne 0$ The function $f(q)$ is negative unless $q$ is between $0$ and $Q$, and is $0$ at $0$ and at $Q$. The function is continuous, so attains an absolute maximum in one or more places the closed interval between $0$ and $Q$. Every such maximum is a local max, so $f'(q)=0$ at every maximum. But there is only one place where $f'(q)=0$, so that place must be where the absolute max occurs.