The correct phrase (adverb) to use traditionally, is: ‘by accident’. It means by mistake or something that’s done without the intention of doing it. For example, “she spilled the milk by accident.” We can also use the word ‘accidentally’ as a replacement for by accident – just two ways of referring to the same thing. Some other synonyms of the phrase include unintentionally or by chance.
Sometimes, what we do or say, even by accident, just backfires; so always be careful.
If I ever hurt your feelings, it was by accident; please let me know so I can apologize.
The glass slipped from my hand by accident.
A far less commonly used variant of by accident - on accident, is almost exclusively used in the United States - and incorrectly so. Even there, no one uses ‘on accident’ in writing; it's only a spoken English term. In fact, it is considered incorrect to be used at all.
Now, some people tend to use on accident as they rationalize that it must follow a similar structure to ‘on purpose’ although the meaning is completely the opposite. Yet another cause of confusion is interestingly the word 'accident' itself!
We had an accidental meeting.
And it can also be a common noun as in:
As explained above, on accident is not commonly used as an adverb phrase, if at all. Whereas, ‘by accident’ is the only correct phrase to use when indicating an unintentional or accidentally carried-out action.