Yeah, that's the point of a vaccine, and that's what they do, but nothing is going to be a magic bullet. There's no 100% protection in a vaccine, that's been the case since they were first invented.
But what they can do is train your immune system to fight it, and that's exactly what they do.
The vaccine releases some of the mRNA of the SARS-nCOV-19 virus into your bloodstream, which doesn't actually have enough data to create a virus. However, your immune cells recognize it as a foreign material in your body, and attack it. The antigen data is then stored in your white blood cells
Then, if any COVID viruses enter into your body, there's about a 95% chance that your immune system will recognize it from the mRNA it saw earlier and have a chance to attack it before it spreads.
That is how vaccines work. They give your body an example of a pathogen, and then let your body fight it so it can learn how. So when it sees it for real while it's alive, it'll recognize it and know how to fight it.