How does a vaccine for a particular disease immunize the body against that disease?

Vaccine is an antigen.When it enters into the body, it stimulates the production of antibody and memory cell which is called primary response.It does not cause harm when this pathogen enters second time.These memory cells show rapid and massive responses so body become immune to this pathogen.