Well, throwing up is a sort of a normal part of the cat life and I don't see why you would think taking shots would prevent that. Especially because if your cat throws up because they're sick or something, taking shots won't magically cure them.
A cat could throw up because of many reasons. Every couple of weeks doesn't sound like awfully often anyways and I wouldn't be concerned unless I saw something wrong with the pile of puke. You should take a look at it to see what exactly the cat is throwing up to see what has caused it. It's most likely hairballs because cats swallow a lot of their fur when they clean themselves and they need to get rid of it somehow so it doesn't grow into a giant hairball inside them that they can't get rid of. That's one expensive vet bill.
Does the puke have many unchewed pieces? Cats can be lazy bastard and just vaccuum everything in their mouth without chewing. Those large pieces can cause them to throw up later. The answer can be to either baby them and cut everything tiny or give them large pieces of meat they have to chew so they can eat it. Though watch out, if your cat decides to go fuck the rules and tries to swallow that... Well, that could lead to suffocation.
Is it mainly dry food? Your cat might be eating too much of it. The dry stuff expands once it gets wet so that can cause many animals to throw up. Maybe limit the amount of dry food the cat can eat.
While your cat doesn't throw up often enough for this to be very possible, I'll mention it anyways. Does it happen after they have eaten some particular food? The cat's stomach could be sensitive to it or the cat might even be allergic. Though I'd assume you would get a lot more throwing up unless there is some food you only feed them rarely and that is what causes it.
If the cat doesn't seem to throw up nothing, it could also be because their stomach is empty and they are hungry. Cats are small animals with a fast metabolism. They need to eat often and long times without food is dangerous to them.
Lastly and what most likely is the issue, hairballs. Even if the cat doesn't throw up a hairball, there could be a lot of hair in whatever they throw up, hidden in the puke. You should brush your cat often so that there's less fur that gets inside them to cause this and you should grow them grass too. It helps them to be able to pass the fur with stool instead of throwing it up - though of course, sometimes the long tufts of grass they eat could cause them to throw up anyways, but if you keep your grass away from any soft surfaces, they would hopefully do it on a surface that's easy to clean.
Watch out though. There this one plant called the Cyperus zumula which even is called cat grass and sold as such. Other people say it's safe for cats while others say it's very poisonous to cats. No one seems to quite agree and some people do report their cats reacting badly to it. I wouldn't take the risk myself, you could get something like oat seeds instead which most likely would be cheaper too. Don't buy any grass that doesn't say what it actually is so you can see if it's safe.