There are many infectious diseases that dogs and cats can get. Fortunately there are vaccines to protect them. Kittens and puppies normally get immunities for common disease while nursing.
Mothers milk contains antibodies which keep the young animals safe until they are weaned.
Shortly after weaning they lose their ability to fight these diseases. Vaccinations rebuild this immunity. Initially a series of vaccinations are needed, to keep an active immunity and to prevent infectious diseases such as parvovirus and distemper which can be fatal. Vaccinations are than needed yearly through out the animals life.