There's a long list of medications that can cause weight gain: birth control pills, excess hormones for hormone therapy, steroids, beta-blockers for heart disease and blood pressure, anti-seizure medications, breast cancer medications, and even some migraine and heartburn medications, you may notice pounds creeping on. Also, many anti-depressant medications cause weight gain. If you're depressed and taking pills for it, look ahead to gaining between 5 and 15 pounds, with sustained gradual accumulation over the years. But many experts claim that there’s evidence that feelings of depression can correlate to weight gain, even without the pills.
But to mainly answer the question here, yes. Technically, you can gain weight from vitamins. This is because any excess taken in the body is transported to the liver, if the liver realizes it and the body does not need said vitamin, it is turned into fat. Also, some multi-vitamins can aid with building lean muscle mass causing weight gain. These multivitamins that promote muscles should be done along with regular workouts. They're usually for athletes.
If you need to take multivitamins and you're bothered that it makes you gain weight, there are plenty of supplements you can take that also encourage weight loss. You can have the best of both worlds by getting nutrients and losing excess fat, if you find the right supplement for you. Work with your doctor to find a medication that treats your symptoms and lessens side effects.
What's important is you have a proper diet rich in fiber and protein, and you aren't malnourished and nutrient-deficient. Don't binge on unhealthy stuff any other time. You should also exercise 3-5 times a week.