Consider the following false claim:
Let $f:[a,b]\to\mathbb{R}$ be a continuous function. A point $x_0\in(a,b)$ is called a local maximum point iff there is a neighborhood $N$ of $x_0$ such that $\forall x\in N\backslash x_0\ f(x)<f(x_0)$ (note the $<$ sign). Then, a global maximum point $x\in[a,b]$ is either a local maximum point or one of $\{a,b\}$.
This claim is easily falsified by the following piecewise function, which is constant in $[1,2]$:
$$f(x)=\begin{cases}x&x\in [0,1]\\1&x\in [1,2]\\3-x&x\in [2,3]\end{cases}$$
In this case the global maximum is achieved anywhere in $[1,2]$, but none of these points satisfy the definition of "local maximum point" because of the $<$ sign in the definition instead of $\le$.
Question: is there a counterexample that is constant on no intervals?
Remark and motivation: apparently, the above false result is stated in multiple Chinese junior high school textbooks. However, for some reason, the problem went unfixed -- the gaokao problems on differentiation usually do not involve functions constant on some interval!
A counterexample is afforded by
$$ f(x)=x^2\left(\sin\frac1x-1\right) $$
on any interval with $0$ in its interior. This function is not constant on any interval; it’s continuous and non-positive and vanishes at infinitely many points in every neighbourhood of $0$; so $0$ is a global maximum but not a strict local maximum.
You didn’t give a definition of a global maximum, but it seems to be implied in your example that a global maximum is not defined as a strict global maximum, whereas a local maximum is defined as a strict local maximum; that seems slightly inconsistent.