A vaccine is effective by triggering a small immune reaction within your body. They are essentially very small amounts of X virus, so that your body can trample it and build an immunity to the real thing.
I mean the short version is "everything does". The human immune system is psychotic to the point that we have organs it has to be kept isolated from or it will destroy them.