Some have mentioned the Fabius function as one close to being a counterexample. I think the following example might be of interest. The function $f$ is almost everywhere locally a polynomial but not one itself. It is constructed similarly to the Fabius function.
Define the sequence of real-valued functions of domain $[0,1]$, $(f_n)_0^\infty$ as follows.
\begin{align}
f_0(x)&=1\\
f_{n+1}(x) &= \frac92\int_0^x u_n(t) \, dt\\
\text{where } u_n(x) &=
\begin{cases}
f_n(3x) \text{ if } 0\leq x<\frac{1}{3}\\
0\text{ if } \frac{1}{3}\leq x <\frac{2}{3}\\
-f_n(3x-2) \text{ if } \frac{2}{3}\leq x \leq 1
\end{cases}
\end{align}
Then $(f_n)$ converges uniformly to a function $f:[0,1]\to\mathbb{R}$. Some of its properties are the following.
- $f$ is infinitely differentiable.
- For every $x\in [0,1]\backslash\mathcal{C}$ (where $\mathcal{C}$ denotes the [Cantor set][1]) there exists a neighborhood $(a,b)\ni x$ on which $f$ coincides with a polynomial. In fact said neighborhood is widest when $a = \max(y\in\mathcal{C}:y<x)$ and $b = \min(y\in\mathcal{C}:y>x)$. Nicely, that polynomial gets matched by all $f_n$ on $(a,b)$ when $n\geq N$, for some $N$ (depending on $x$).
- If $x\in\mathcal{C}$ and $x$ is a unilateral limit point of $\mathcal{C}$ then by continuity the derivatives of $f$ at $x$ will eventually vanish. If $x$ is a bilateral limit point of $\mathcal{C}$ then the derivatives of $f$ at $x$ are all non-zero.

So a close call. The function looks [like this][2].


  [1]: https://en.wikipedia.org/wiki/Cantor_set
  [2]: https://i.sstatic.net/2jGZP.png