When talking about the beach, there are times when one could use either "on" or "at" without much change in meaning, but other times where there would one would be more preferred than the other.
Ngrams won't be very useful when trying to figure out the "right" preposition, because there are plenty of contexts where one preposition might seem more natural than the other – even though the two might be almost interchangeable in other contexts.
For example:
They built a new cottage on the beach.
They built sand castles at the beach.
Two whales washed up on/at the beach.
Generally speaking, on the beach is roughly equivalent to at the seashore. The first sentence doesn't mean that the house was atop the beach, it means the house was near the seashore – that it had an oceanfront view.
The second sentence is describing the geographic location of the activity, more so than describing the location of the property. Using on wouldn't be incorrect, but I'd strongly prefer at in that sentence.
In the third sentence, either word could be used. I've spent the last several minutes trying to formulate an explanation, but was unsuccessful: no matter how I dissected it, I was able to come up with counterexamples that would refute my explanation.
Bottom line: Even when confining the analysis to "the beach," sometimes the two prepositions are more interchangeable than others.