Have you heard of memory cells?
Simply, when you face with an antigen, anticores are produced. Then the body keeps in mind the antigen, and if the antigen comes again, it responds more quickly. That’s why vaccines are used. You make the body aware of the microbe. But you con not use the infecting thing directly, as it will make the person ill.
When people are vaccinated they are immunised against disease by introducing a mild, or dead, form of the infecting organism into their bodies.
What does it mean by ‘the dead form of the infecting organism’?
Pathogenic organisms, or organisms that capable to trigger an immune response has a specific structure that called as "nonself" structure, for instance lipopolysaccharide from bacteria. The dead bacteria then being administered thru immunization to expose our immune system to recognize it. We use dead organism because it is harmless and will not generate illness (just activate an immune response) that threaten the individual immunized.
Beside applying dead pathogens, we also use fragments or debris from pathogens, you know the part of organisms for instance bacteria cell wall. All things our immune system is epitope or part of pathogenic organism that capable to induce the immune response. Once our immune system recognize this epitope, not necessary to be a whole organism, our immune system will immediately work.