I can understand $\frac{d^2y}{dx^2}=0$ being the case at an inflexion point: To the left of the inflexion point the gradient is increasing and to its right the gradient is decreasing (or vice versa), therefore the rate of change of the gradient is negative to the left and positive to the right (or vice versa) which means that the graph of the rate of change of gradient crosses the $x$-axis at the point of inflexion, i.e. $\frac{d^2y}{dx^2}=0$.
However, when I tried to apply this thinking to $\frac{d^2y}{dx^2}=0$ at a maximum point it doesn't seem to make sense. Here is my attempt: For a maximum point with $\frac{d^2y}{dx^2}=0$, as we move from the left of the maximum point to the right, the gradient must first be decreasing, then stop decreasing at the maximum point (otherwise $\frac{d^2y}{dx^2}=0$ doesn't hold), then continues to decrease past the maximum point.
The part where the gradient stops decreasing is what I don't understand: Surely a gradient can only stop decreasing at some point if the curve near that point is a horizontal line? (Otherwise it will be decreasing at every point in the locality of the point.) Does this mean that a maximum point satisfying $\frac{d^2y}{dx^2}$ is a horizontal line near the maximum point? I tried "seeing" this by using the fact that a graph becomes flatter at a point where there is a double root (which is the case for a maximum point with $\frac{d^2y}{dx^2}=0$ since we also have $\frac{dy}{dx}=0$ at that point), but flatter doesn't mean horizontal so this explanation doesn't seem to work either.
Where am I going wrong?
Edit: There seems to be a misunderstanding. I know that the second derivative at a maximum may not be zero; I am simply looking for an intuitive explanation of how it can become zero. In particular, I am trying to understand how (obviously in cases where $\frac{d^2y}{dx^2}=0$ at a maximum, or a minimum, for that matter) the fact that $\frac{d^2y}{dx^2}=0$ is consistent with the graph only being horizontal at one point, namely the maximum. My intuition is telling me that for $\frac{d^2y}{dx^2}=0$ to hold, the graph has to be "momentarily" horizontal rather than just horizontal at one point, i.e. it has to be a straight horizontal line in the locality of the maximum - but this isn't the case for e.g. $y=x^4$ and yet at the minimum $x=0$ we have $\frac{d^2y}{dx^2}=0$. How is this even possible - the graph does not stop and become "momentarily" horizontal at $x=0$ all of a sudden does it?
The 2nd derivative may be zero at a maximum point. Example: $$ f(x)=-x^4 \quad\mbox{ at } x=0. $$ The 2nd derivative may also be nonzero at a maximum. Example: $$ f(x)=-x^2 \quad\mbox{ at } x=0. $$ In a lot of practically important cases (e.g. in physics) it's nonzero.
Note that, in both examples above, the graph of $f(x)$ itself is a curve, and not a horizontal line. The tangent to $f(x)$ graph at the maximum is horizontal in both examples.