First off, it's indeed with, not to. You lodge, or file, or register, or raise a complaint with someone. However, you can also submit, bring, take, or send it to someone.
Here are some stats from the Corpus of Contemporary American English just to drive the point home:
filed a complaint with/to 131/1
file a complaint with/to 42/2
filing a complaint with/to 11/0
lodged a complaint with/to 6/1
lodge a complaint with/to 5/0
files a complaint with/to 4/0
lodges a complaint with/to 1/0
Why? There is really no why, especially not when it comes to prepositions. One is idiomatic, the other one isn't. You learn to use with from your mom because that's what she uses. And she in turn learned it from her mother. That is all there is to it.
This is not really too different from how you use "a car" to mean "a car". It might just as well have been "uma João". But you say "a car". And prepositions in particular are more idiomatic than anything else. They do not have to follow some logic, and indeed often don't. In every language, not just English.
And one last thing. You say "the definition of 'with' is 'accompanied by (another person or thing)'". That is not true. That is one definition of 'with'. A good dictionary will have a dozen more, including one that covers "lodge/file a complaint with". Usage follows definition, but definition also follows usage.
Note how if you say "I'm married with three kids", you don't label yourself a polygamous pedophile, either. And as I commented on that other question, in German, which is closely related to English, one is actually married with someone and it's "married to" that would be ungrammatical. In Russian, you'd be married on your wife, while she is married behind you. That goes to show that there is no one true universal meaning to any given preposition. Current usage = coincidence + tradition.
Best Answer
Both are new expressions, and haven't gone through the full evolutionary process yet. Both are used, and both are useful. Also, they both make sense, which is not a requirement, but always helps.
Usually in refers to a 3-dimensional container, while on refers to a 2-dimensional surface.
So the question is whether an email has 2 or 3 dimensions. Then the rule will be:
Unfortunately, however, the whole phenomenon of email happens metaphorically, so there's nothing with any real dimensions to hold on to. The only thing one actually sees is letters on a screen arranged in a particular way. It turns out that there are two metaphorical ways we can interpret, speak about, and think about it -- or at least that's all we've thought of so far. Email is pretty new.
One way is to use the metaphor theme
Since letters are on paper, and paper is 2-dimensional, this allows on. That is, we speak (and think) of the email as being flat; therefore something can be on it.
The other metaphor theme that we use is to focus on the contents of an email.
Containers are almost exclusively 3-dimensional, so this allows in.
Both views are reasonable, though neither is actually real. Computers are so new in our experience that we're constantly inventing new metaphors to talk about them, and we can switch views without blinking, or even noticing what we've done. After all, all computer terms are metaphors, dragged in from somewhere else and assigned a new meaning -- for instance,