The protection of vaccines
When bacteria or viruses enter the body, whether it be human or animal, the immune system kicks in to fight it off. It does this by producing antibodies which fight the invader and protect against infection.
When the body first encounters a bacteria or virus, it takes time for it to recognise the invader. The immune system can take several days before it has produced the right specific antibodies to help overcome the infection. During this time, the invader can cause infection and disease. If the immune system produces the right antibodies in time it can then start tackling the invader to protect itself.
After this has happened, the body remembers the invader and keeps some memory cells. These cells will recognise the invader straight away if it infects again and can deal with it much faster and help prevent disease.
Vaccines are used to prime the body to recognise the invader before it has encountered it. It does this by imitating an infection without causing any illness or disease. This way the body responds in the same way it would if it was truly infected, and will create memory cells to deal with the infection faster next time.
Vaccines can do this because the exposure to the virus or bacteria has been altered to stop it creating disease. This is done in many ways including killing the virus first, or using a virus that has been weakened so it cannot cause disease, however this most often means the response created isn't strong enough for the body to have complete immunity. This is why most vaccines require a booster shot three to four weeks after the first vaccination. The body's response to the second vaccination will be much greater and faster, producing a large number of antibodies.
This means that when the body does actually encounter the live invader, it will be better equipped to deal with it and prevent infection.
Vaccines also work by sometimes allowing the body's memory antibody cells to be passed to their young through the colostrum. This is why colostrum is so important in young animals as it can provide them with a more equipped immune system to deal with diseases as soon as possible.