Suppose $x_0$ is a local maximum. Assume $x_0$ is not an absolute maximum. Then $\exists x_1 \in I$ with $f(x_1) > f(x_1)$. Let $I'$ be the closed interval from $x_0$ to $x_1$. Let $x'$ be the global minimum of $f$ on $I'$.
Then we can choose $x' \ne x_0$, as $x_0$ is a local maximum for $f$, so there is a small open interval $V$ about $x_0$ in $I$ with $f(v) \le f(x_0)$ for $v \in V$.
Also, clearly $x' \ne x_1$.
So, $x'$ is an interior global minimum point for $f$ on $I'$, so $x'$ is a local minimum for $f$ on $I'$ and hence for $f$ on $I$, contradicting the status of $x_0$ as the unique local extremum for $f$ on $I$.
The case for $x_0$ a local minimum is similar.