As previously described in detail, a pathogen stimulates your immune system to create antibodies and memory cells that fight against a given disease. A vaccine harnesses the same process but allows the body to create the antibodies and memory cells without having to suffer through the complete illness! The key step is that instead of using the actual pathogen as the stimulating agent, the vaccine presents either a weakened or attenuated form of the pathogen, or inactive parts of the pathogen.
These slightly different stimulating agents are still sufficient for your immune system to create the necessary, long-living memory cells. These memory cells will help your body fight off the original pathogen if you are ever exposed to the disease in the future. In other words, you become immune to the pathogen.
However, these slightly different agents are not able to give you the complete illness. Instead, you will either have no symptoms or at most develop a milder form of the disease.