Anvi, the basic reason is that the value of a stock depends on future profits of the company. If it's earning less than expected it can be seen as evidence that future profits will be lower than expected. Then the stock is worth less than before.
Note that it isn't binary. There is nothing contradictory in a company being profitable and its stock falling, since it isn't falling to 0. It's still worth something just not as much as you thought before.
Yes, I understand the non-binary nature of it. But whose expectations? Those of the investors? What are their expectations based on? How do investors know what future earnings are "supposed" to be given the inherent uncertainty about markets...and about the future in general? And if a company doesn't perform up to expectations, is there any careful consideration or analysis of why it came in under them before its stock is sold? Maybe in some cases, but I'm skeptical about whether the expectations process is altogether as rational as some might argue.
But maybe what I'm expressing, given my general ignorance about econ, is not so much an objection to the process as sympathy for some of its victims. A company continues to make a profit but its stock falls. Business is a damned tough beat.
Yes, the investors invest based on their expectations. They base that on the best analysis they can provide. Which of course is not perfect, but they do pay some pretty smart people to work very hard at those.
That we do not know the future perfectly is the reason why stock prices fluctuate. If a company reports a profit that was below expectations it may be a sign that expectations on the future were also inflated.
Note, there is not really a "supposed". There is just the analysis people make. Think of it as a political race. Let's say that you think Vermont is D+15 in a presidential election. Let's say you expect the D candidate to win 52-48, so D+4 nationally. Let's say Vermont gets called as D+10 early in the night. Based on your expectation (which was based on your analysis of the polls, racial breakdowns, issues, etc) this is bad news for the D candidate. Sure, they won a state but they won it below expectations and you might think that an underperformance of 5% on the margin will translate nationally into a 1 point loss nationally.
Not sure if that made it more or less comprehensible but at least I tried.