Everyone's familiar with a brain freeze: You eat or drink something cold a little too fast and suddenly your head erupts in a flash of pain. We all get them and try to avoid them, but this video explains why they happen at all.
Long story short for the folks who can't watch the video, the going theory is that brain freezes happen when the brain interprets rapid constriction of blood vessels in the mouth and palate as pain — the cold sensation and blood vessel constriction trigger the trigeminal nerve, which tells the brain "something's wrong in my face" and your brain does what it needs to so you stop doing that thing — the "thing" in question is usually eating ice cream, drinking a milkshake, or enjoying some delicious shaved ice.
In fact, the video (from Mental Floss, linked below) explains that people who are more susceptible to migraines are also more susceptible to brain freezes, and researchers hope that by studying them, they will get a clue into how migraines and other headaches work and how to treat them more effectively.
As for what to do about them? Well the answer is the same as you've been told your whole life: when you're eating something cold, slow down. If you really need a countermeasure, a glass of warm water or something may help you recover a little more quickly than you would otherwise.
What's a brain freeze? [Mental Floss (YouTube)]