When exposure to a pathogen identical to one that has been encountered previously occurs again, the immune system recognizes the pathogen and acts quickly based upon:
The PAMPs are "markers" on the pathogen that the body's immune cells will recognize via the PAMP recognition receptors (PRRs).
The memory cells of the body will recognize the pathogen faster because these cells have a 'memory' of the pathogen and can initiate a faster, more robust response.