The story
From brain + storm. In the sense of "seizure, convulsion, brain activity", from the idea that it is like a storm in the brain. In the sense of "problem-solving idea or session", from the unrelated idea of using the "brain to storm a problem" (see brainstorm).
Etymology from Wiktionary, CC BY-SA 4.0.