Why do we need an open interval to define local maxima? We say that $f(x)$ has a local maximum at $\tilde{x}$ if  for every $x$ in some open interval $(\tilde{x}-\delta,\tilde{x}+\delta)$, $\delta>0$ we have $f(\tilde{x})>f(x)$.
Why do we need an open interval? Why can't a closed interval be good enough?
 A: We actually need a neighbourhood of $\tilde x$; i.e. a set that contains an open interval around $\tilde x$. This is just by definition of what "local" means.
E.g. to be a local maximum would be a pretty empty statement if we were allowed to use the closed interval $[\tilde x,\tilde x] = \{\tilde x\}$... We thus (intuitively) need to look at what other values $f$ attains "close to $\tilde x$", or, "in a neighbourhood of $\tilde x$"; there you go :).
Another example to show that a general closed interval will not suffice (it is obvious that $[x_0,x_1]$ must have $x_0 = \tilde x$ or $x_1 = \tilde x$ or $\tilde x$ would be in $(x_0,x_1)$ as well, i.e. $[x_0,x_1]$ would be a neighbourhood of $\tilde x$ after all). Namely, take $f(x) = x$ and the interval $[-1,0]$ about $0$; since $f(x)>0$ for all $x >0$ it is not natural to regard $0$ as a local maximum of $f$.

On the other hand, if $x_0 < \tilde x < x_1$, then $[x_0,x_1]$ contains the open interval $(x_0,x_1)$, hence is a neighbourhood. In this sense, closed intervals where $\tilde x$ is not the endpoint are fine. Moreover, if we have an open interval $(\tilde x-\delta, \tilde x+\delta)$, then we have the inclusions:
$$\left(\tilde x - \frac\delta2, \tilde x+\frac \delta2\right) \subset \left[\tilde x - \frac\delta2, \tilde x+ \frac\delta2\right] \subset (\tilde x -\delta, \tilde x +\delta)$$
showing that "closed intervals where $\tilde x$ is not the endpoint" provide an equally valid notion local maximum as "open intervals" (but of course the latter is shorter). Thus taking closed intervals in your definition is equivalent to taking open intervals.
The reason for preferring open intervals is that in the more general field of topology, they generalise to so-called open sets, while closed intervals generalise to closed sets. But in general, not every neighbourhood (with open sets rather than intervals now) will contain a closed subset that is still a neighbourhood (however, as we have seen, this is true in $\Bbb R$). So, as there is only one of the two definitions that generalises in a natural way to general topological spaces, your book/professor has decided to give that definition, avoiding unnecessary confusion later on.

Lastly, let me elaborate on why this notion of neighbourhood is "natural". For suppose that there were no (set containing an) open interval $(x_0, x_1)$ about $\tilde x$ satisfying the given condition. Then for this to be possible, we need that:
$$\forall \delta > 0: \exists x: |\tilde x - x| < \delta, f(x) \ge f(\tilde x)$$
This means: "however close you look at $\tilde x$, there is always a point $x$ in your scope where $f(x) \ge f(\tilde x)$." Now hopefully you agree that such $\tilde x$ should not be called a local maximum.
A: For $\,(x_0,f(x_0)) \,$ to be a local maximum we need that here
$$\exists\,\epsilon>0\;\;s.t.\;\;f(x_0)\ge f(x)\;\;\forall\,x\in(x_0-\epsilon\,,\,x_0+\epsilon)$$
It's a matter of definition. Funny enough, whenever a function's definition domain has end points its values of the end points automatically (i.e. by definition) are local extrema...
A: If we use closed interval instead of open then for any function $f:A\to \mathbb R$, any point $x_0\in A$ where $f$ is differentiable at $x_0$,  will be a local minimum or maximum:

If $f'(x_0)>0$ then using the $\epsilon-\delta$ definition of the limit it is not hard to show that there exist a $\delta>0$ s.t. $f(x)>f(x_0)$ for all $x\in(x_0,x_0+\delta)$...
