Immunity is the ability of the body to defend itself from 'foreign bodies'. This means rejecting infections, clearing up dust which gets in the lungs, and killing cancer cells.
Immunity is of two types. Innate immunity protects the host against infection, but has no 'memory', and so gives no long-term immunity.
The second type is adaptive immunity, which does have a kind of 'memory'. It does give long-term protection against specific pathogens.