The immune response operates by various mechanisms, both humoral and cellular. The same mechanisms lead to either protection (immunity) or damage (hypersensitivity). It is really semantic, as often both are occurring at the same time. For example, an abscess causes a lot of tissue damage, but at the same time gets rid of the bacteria causing the problem. Similarly, an infection with tubercle bacilli will lead to formation of tissue-damaging granulomas that at the same time wall off the invading bacilli and prevent them from spreading.