A few of the mechanisms that the immune system has to kill things are:
Antibodies. Antibodies are molecules that can “tag” things for destruction. the shape on one end of the antibody is shaped just right to catch onto a specific thing. Hopefully that thing is a bacteria or something trying to make you sick. But the antibody isn’t smart, so if it happens to be a shape that it attaches to your own nerve cells, it still “tags” them for destruction. Antibodies can also play a role in killing things through a process called agglutination. If the type of thing the antibody attaches to is free moving in the blood stream or fluid around cells, then it might bump into lots of antibodies and have lots of “tags” on it. Antibodies are shaped so that the end sticking up after “tagging” something tends to get stuck to the end of other antibodies. So, they mash together in a big mass and the things they are attached to get dragged down and die since they can’t move around and eat and breath.
Sometimes antibodies happen to be shaped in a way that they block some vital function of whatever they attach to and kill it directly, but this is less common.
Things that don’t or can’t be agglutinated though remain “tagged” and then other parts of the immune system kick in.
Once tagged specific white blood cells come along and see the tag, which tells them to “eat” (phagocytosis) it. They do eat it and then literally they have little organells in them that digest them. These guys can only eat so much though, so they die off. That’s what the white stuff we call puss is. Dead white blood cells that ate as much of the infection as they could until they died.
For a great book on this from a genius immunologist that is extremely accessible in his writing (even funny) see In Defense of Self: How The Immune System Really Works.