This piece for Links Beat collects the advice that holds up in practice.
A vaccine shows the immune system a harmless piece or copy of a germ so that it can prepare before the real thing arrives. The body produces antibodies and memory cells, which take a couple of weeks to form. If the actual virus or bacterium turns up later, those memory cells recognise it immediately and the response is fast enough to prevent serious illness.