We talk of ‘an’ immune system, but in fact there are two distinct but inter-connected immune sub-systems; the innate immune system and the acquired immune system.
The innate immune system can react quickly to any threat from a ‘foreign invader’ – and importantly can be ‘primed’ to work more effectively.
The acquired immune system only reacts to a threat it has encountered before – and built up an immunity against.