It shows your body what the pathogen looks like chemically, so it can learn how to identify it and destroy it without you becoming sick. So if you actually do get sick later from same strain of pathogen in the vaccine your body already knows how to fight it so you will not be sick as long or at all.