What are the medical reasons that prevent a person from taking vaccines?

A few. There are a few medical reasons not to receive vaccines, Some people have actual allergies to a component of a vaccine. (pretty rare). Also people with a suppressed immune system (from drugs or illness). Those with severe reactions to childhood vaccinations should probably not have repeat pertussis immunization which is the most likely cause.
Severe allergic rxn. A severe reaction to a component of the vaccine would be a medical reason to avoid future use. A compromised immune system ( chemotherapy, immunodeficiency) would be a reason to avoid living vaccines.
Immune deficiency. if you have HIV or are under cancer treatment and the immune system is not functioning, then a vaccine won't take and possibly could make you sick with the disease. Then some older people have what is known as immunosenesence and don't take vaccines well, so instead of being protected from herpes zoster get a cas of it form a vaccine.
Allergic. Some are derived with egg, or other carriers. Some persons have allergies, or bad reactions. Most times people can take vaccines and will have good results. Small pox Measles, tetanus, polio etc are very minimal since vaccines became available! .