Assuming that you're old enough to have had sex ed, the fact that hundreds of people get pregnant each year while using condoms doesn't mean that they don't work.
According to the NHS of Britain: "When used correctly every time you have sex, male condoms are 98% effective. This means 2 out of 100 people will become pregnant in 1 year when male condoms are used as contraception."
Vaccines are the same. They work, but they aren't a magic shield. They lower infection rates, dramatically lower hospitalization and death rates, but they don't work 100% -- not even well-tested ones like the measles vaccine. Humans and their immune systems are too diverse, and viruses keep mutating (especially Covid, that has so many millions of human petri dishes to evolve in).