Nobody has replied yet so I'll give it a try. I'm not a native English speaker as you know, so I may have some misconceptions about this.
"By" introduces an agent, someone or something that, according to our perception, performs the action. "With" introduces an instrument, something that serves the agent to perform the action.
I was hit by my brother with a stick. My brother hits so he is the agent. He uses a stick, which is therefore an instument.
It's not a very common structure though. Often, when you use the passive voice, you do that because you want to omit the agent.
I was hit with a stick. We don't know the agent but we do know that a stick was used to hit you.
The agent does not have to be a person.
I was hit by a car. Here, "a car" denotes the agent, not the instrument, even though a car is not a person. You may wonder whether cars are really capable of performing actions. Well, I don't know actually, but that's just how the English language sees it.
You're not very likely to say,
I was hit by a stick.
We don't think of a stick as of the agent of hitting. Why can a car be an agent and a stick can't? I think that's because cars seem to have a will of their own and sticks don't. Do you know the etymology of the word "automobile"?
Student or Learner