This phenomenon is also known as sympathy vomiting. Scans of the brain have actually shown that when you see someone vomiting, your brain has the same activity as if you’re the one vomiting. You’re feeling the same disgust that they are. Scientists think that this could be the source of empathy, and may also be an evolutionary tool.
If someone in your family clan ate food that had gone bad, it’s likely that you would have eaten it too. If it caused them to vomit, it would be better for you – from an evolutionary standpoint – to also vomit and get rid of any toxins. Unfortunately, this seems to be hardwired into our brains.