... like I'm 5 years old
Have you ever had that sudden, sharp headache when you eat or drink something cold too quickly? That's what we commonly call a brain freeze. Now, despite what the name suggests, your brain isn't actually freezing. Brain freeze, also known as an ice cream headache, happens because of a rapid change in temperature at the back of the throat, at the juncture of the internal carotid artery, which feeds blood to the brain, and the anterior cerebral artery, which is where brain tissue starts.
Think of it like a car's engine overheating. When you rev the engine too much (or eat ice cream too fast), the temperature gets too high and the car (your brain) doesn't like it. The car's warning lights start flashing (you feel pain) until the temperature goes back to normal.
... like I'm in College
Moving a bit deeper into the science of it, the pain of a brain freeze is essentially a type of headache. When you consume something cold quickly, it cools the blood vessels in the back of the throat and mouth. This rapid cooling and quick rewarming can cause a sort of shock to your nervous system, resulting in a brief bout of pain.
Our bodies are designed to maintain a stable temperature. When the cold substance hits your warm mouth, the body reacts to preserve heat. It does so by causing the blood vessels to shrink (vasoconstrict), then rapidly expand (vasodilate) as they warm up again. This cycle triggers pain receptors, which release pain-causing prostaglandins, increase sensitivity to further pain, and produce inflammation. It's this series of reactions that give you the sensation of a brain freeze.
Imagine you're building a Lego model of a town. The bricks representing the blood vessels are arranged in a certain way to make the town function smoothly. Now, imagine you suddenly drop a bunch of ice-cold Lego bricks (the cold food or drink) into your model town.
The original bricks (the blood vessels) react to these cold newcomers by changing their arrangement (vasoconstriction). Once the cold bricks start warming up, the original bricks also rearrange themselves back to their original layout (vasodilation). But this sudden change in the arrangement causes confusion in the town (the pain).
The tower in the middle of the town, which represents the trigeminal nerve, senses this confusion and reports it to the town hall (your brain), which interprets it as a ‘freeze’. But as soon as the cold bricks are the same temperature as the rest, everything goes back to normal. The tower stops reporting, and the town hall stops interpreting the confusion as a freeze, and so, the brain freeze ends.
... like I'm an expert
From a clinical perspective, sphenopalatine ganglioneuralgia, or what we commonly call a brain freeze, can be seen as a neurophysiological response. It's an excellent example of referred pain, where the pain is felt in a location other than where the problem actually is. The pain is thought to be a result of the trigeminal nerve, the primary nerve for facial sensation, which also senses temperature changes and pain in the facial area.
The rapid cooling and rewarming of the capillaries in the palate can stimulate this nerve and cause the sensation of pain. This rapid-onset neurologic event is quickly reversible with the cessation of the cooling, which is why the discomfort of a brain freeze usually subsides as quickly as it arrives.