The definition is broader than that. Think of a vaccine as something which teaches your immune system to fight some particular thing.
The most common application is as a preventative measure to protect you from an infectious disease. But it can be used for other diseases (like cancer, which is not infectious) and it can be used after you're sick.
Fun fact: if an unvaccinated person is exposed to measles, they can get the MMR within 72 hours of exposure, and it will still reduce the severity of the disease. (Source: https://www.cdc.gov/vaccines/vpd/mmr/public/index.html )
The most common application is as a preventative measure to protect you from an infectious disease. But it can be used for other diseases (like cancer, which is not infectious) and it can be used after you're sick.
Fun fact: if an unvaccinated person is exposed to measles, they can get the MMR within 72 hours of exposure, and it will still reduce the severity of the disease. (Source: https://www.cdc.gov/vaccines/vpd/mmr/public/index.html )