causing pain to the child is not a part of what facilitates the end of giving them immunity — Bob Ross
It is not just pain, injections cut through the child's skin.
The reply applies all the same to self-defence: are you harming someone who feels no pain if you break their legs, stopping them from hurting you? Well, you broke their legs, but they will heal; you cut through the child's skin, but it will heal. Both cutting through the skin and breaking their legs are means to the end of immunisation and self-defence.
The problem you are having is that you don’t have a refined conceptual understanding of what a means is. — Bob Ross
A means is something that facilitates the end — Bob Ross
That is not really what "means" means, as the dictionary will show, but I can fly with whatever definition you prefer. The usage of "facilitate" however is definitely troublesome, I take it you mean "enables the end"; whether is made easier or harder is unimportant.
I mean the flow of intention—e.g., an archer aiming at their target. — Bob Ross
I don't know what the phrase "flow of intention" is supposed to mean, you will have to be more specific. Someone either intends something at a moment or not, it doesn't flow. An archer aiming at their target is an action, an action which can be intentional or not.
Whether or not one directly intends something matters, because moral agency is agent-centric. — Bob Ross
So is the problem that we intend to harm the attacker for the sake of our self-defence, while we don't intend to cause pain for the sake of vaccination but that we intend to vaccinate and it happens to cause pain?
People who vaccinate know about the pain. In a self-defence situation we know what is going to happen if we shoot the assailant. I will say again that whether it is idiomatic in English to say we "intend" one while not intending the other seems unimportant, we know of the consequences of our actions, they happen.
Take for example if we had no clue how vaccines worked. We just knew that they did work and that they are painful. In that case, our intention would be to cause this specific kind of pain that is only caused by vaccines, because we thought that the pain is what gave immunity. So we are intending to harm for the sake of something good, it is morally fine.
I will say again that it is 2 that is problematic and ought to be rejected. 3 is not. Harming someone is, in itself, bad, but the harm might be outweighed by a good.
You
could reject 3, but there are reasons against it.