There are two different types of vaccines: those with killed versions of the antigens (a foreign substance that induces an immune response), or with only part of the live antigen that causes the disease. These types of vaccines are completely incapable of causing a person to develop the disease. Vaccines made with live, attenuated (weakened) antigens can theoretically cause illness, but the likelihood of doing so is extremely small.
Live, attenuated (weakened) vaccines can still replicate (though not well), and mutation is possible, which can result in a virulent form of the pathogen. However, vaccines are designed with this in mind, and attenuated to minimize this possibility. Reversion to a virulent form is a problem with some forms of the oral polio vaccine (OPV), which is why only the inactivated form (IPV) is now used in the United States.
It is important to note that attenuated vaccines can cause serious problems for individuals with weakened immune systems, such as cancer patients. These individuals may receive a killed form of the vaccine if one is available. If not, their doctors may recommend against vaccination. In such cases, individuals rely on herd immunity (community immunity) for protection.
As to why some vaccines contain live pathogens and others contain killed pathogens, the reasons vary by illness. However, generally speaking, live, attenuated vaccines generate longer-lasting immunity than killed vaccines. Thus, killed vaccines are more likely to require boosters to maintain immunity. Killed vaccines, however, also tend to be more stable for storage purposes, and can’t cause illness. The medical community must weigh these trade-offs in deciding which approach to use against a particular disease.