Bacterial toxins are bacterial waste products. Bacteria eat and excrete. It would be much better for bacteria to cause no disturbance, because you wouldn't have to kill them. In a certain way, bacteria seem to use their excretions as weapons against immune cells and body tissue. But bacteria can't think! The ones that survive are the ones that developed a gene mutation for, let's say, elastase secretion. Immune cells secrete elastase to destroy the elastin holding together the individual bacterium.
After a while, the bacteria began secreting elastase to destroy the elastin in immune cells. The lungs are replete with elastin, because they require elasticity, also called, compliance. So, elastase-secreting bacteria can cause pneumonia. The immune cells and the bacteria are firing elastase at each other, and the lung tissue is caught in the crossfire.