Where do market “bubbles” come from? A team of neuroscientists and economists has produced the first scientific evidence for what prudent investors have long believed: Paying attention to what others are doing is the easiest way for traders to get carried away.

This new research can’t prevent the mass contagions that lead to bubbles. But it might help you step back before you get swept up in the next one.

Economists have struggled and failed to explain why markets turn into manias. Some have denied bubbles exist; others have argued bubbles must somehow be “rational.” Often, the argument is that bubbles are caused by “uninformed” traders, or “dumb money,” while the “smart money” sits on the sidelines.

The latest findings suggest, however, that bubbles might be caused not by traders who lack information but by those who have too much.

The new research, published this month in the journal Neuron, was conducted by economists, psychologists and neuroscientists from the California Institute of Technology, Royal Holloway University in London and the University of Utah. The study was led by Colin Camerer, an economist at Caltech—who, coincidentally, won a MacArthur “genius award” this past week for his innovative studies of financial behavior.

In the experiment, Caltech students had their brains scanned while they viewed a stock being traded in a laboratory game. In that experimental market, the fundamental value of the stock was based on its payments of dividend income and declined almost to zero by the last round.

In half the sessions, the participants viewed trading that hadn’t resulted in a bubble, with prices that quickly converged on fundamental value. In the other half, traders had driven the stock to multiples of two, three and four times fundamental value, creating bubbles that then burst—wiping many of them out.

But the participants didn’t just watch the trades of others; several times during each round of the game, they got the chance to trade at the latest market prices.

Later, the researchers tested how accurately the participants could infer what is on another person’s mind based on a photograph of his or her eyes.

Those who scored high on this test showed greater “activation,” while they were trading, in a region of the brain associated with imagining what others are feeling—especially during bubble markets. In normal markets, activation in that part of their brain, called the dorsomedial prefrontal cortex, was unrelated to their trading performance.

That suggests that traders pay more attention to what others are doing in the midst of a bubble than they do in placid markets.

Furthermore, those with the worst tendency to “ride the bubble”—buying more enthusiastically as prices soared away from fundamental value—paid particularly close attention to other traders’ actions.

“People seem to be buying,” Prof. Camerer says, “because they think they can sell to somebody else who isn’t able to control himself as well as they can or isn’t as prescient as they are.”

In other words, as prices rise and you intensify your search for that “greater fool” you can sell to, you may get distracted from noticing that the greatest fool of all is you.

The people in the experiment interpreted changing patterns of trading volume as information about where prices were heading—regardless of whether it had predictive power. The traders who were most likely to ride the bubble too long were those whose brains responded most intensely to sudden shifts in trading volume.

“When there are these trading bursts,” Prof. Camerer says, “a lot of people may get an exaggerated sense that they can predict what’s next.”

The study was based on a small sample of students, not professional traders, and didn’t look at other possible explanations for bubbles like emotional arousal or the wish to conform. Still, it rings true.

“If everybody else is doing something silly, maybe you should detach the network and social links that make you susceptible,” Prof. Camerer says.

“You could live in Omaha instead of New York,” he adds, in an allusion to Warren Buffett’s deliberate detachment from the daily hubbub of trading. “Getting away from the market and media bubble might help you avoid a financial bubble.”

You also can use a checklist with rules like these: Never buy a stock or other asset purely because its price has been going up or sell just because it has been going down.

Before you buy, list several reasons—other than price—that make it a good investment. After any big up or down move, review those reasons and ask whether the new price has invalidated them.