The heritable immunity you are describing is due to selective pressures on populations where individuals with certain alleles have a survival advantage in the face of particular pathogens. If a population is exposed to deadly diseases like smallpox and there are some individuals in the population who are more resistant, those individuals are more likely to survive to reproduce so future generations will have more resistant individuals. You could think of this as immune system "hardware."
Vaccines trigger the immune system's ability to recognize past infective agents and therefore mount a rapid specific antibody response when exposed to that pathogen again. You could think of this as immune system "software." This software that is aquired during the lifetime is not present in the genome of germ line cells and is not transmitted to offspring.