Saying you "accidentally" did something is the only correct way. Saying you did something "on" accident or "by" accident is incorrect. The accident is not a person, place, or thing. You could neither have been on it nor by it when you did whatever you did.
Congratulations. You've just made me go full Grammar Nazi.
You don't sleep in a bed, either, you sleep
on a bed. Are you going to try to tell me that the phrase, 'I'm in bed,' is grammatically incorrect?
And for what it's worth, 'by' doesn't have to indicate position. Your homework must be done by the due date.
By can be an indicator of the cause of something, or to place responsibility for some event or action. 'Jane was hit by the truck,' might (incidentally) indicate the truck through position, but, 'Jane was put in the hospital by the truck,' indicates not that the hospital is adjacent to a truck, but that the truck which hit her was the cause of her hospitalization. Similarly, an accident can be that cause—so that morning, Jane put salt in her coffee
by accident. An 'accident' was the cause of her putting salt in her coffee, as indicated by the word 'by' (and in this sentence, 'by' indicated that 'the word "by"' was the cause of the accident being indicated
).
Grammatik macht frei.
Edited by Anastasia, 16 November 2014 - 02:35 PM.