A vaccine is a weakened form of the disease causing bacteria injected in to the patient. The person then develops immunity to that bacteria and so when they are infected with the bacteria, they are able to quickly fight against it without feeling any symptoms.
The vaccine doesn't cause disease, as the pathogens aren't strong enough to cause harm.