A stock price is what the last buyer paid the last seller. That's the entire mechanism. Everything else is an explanation of why those two agreed.
This sounds too simple to be useful. It isn't, and holding onto it protects you from most of what you'll read about markets.
The mechanism, literally
At any moment there's a highest price someone is willing to pay, called the bid, and a lowest price someone is willing to accept, called the ask. The gap between them is the spread.
A trade happens when a buyer accepts the ask or a seller accepts the bid. That transaction price becomes the quoted price. Not a committee's opinion, not a valuation, not what the company is worth. One transaction between two people, the most recent one.
When you see a stock "at $50," what you're seeing is that the last trade cleared at $50. If nobody trades it for an hour, it stays at $50 regardless of what happens to the business in that hour.
So what moves it
Prices move when the balance between willing buyers and willing sellers changes. More demand at the current price than supply, and buyers have to bid higher to get filled. More supply than demand, and sellers have to accept less.
That's supply and demand, which sounds like an evasion until you ask the next question: what changes people's willingness?
Four things, mostly.
Expected future earnings. A stock is a claim on a business's future cash. New information that changes what people expect that cash to be, an earnings report, a guidance revision, a lost contract, changes what they'll pay for the claim.
The discount rate. Future cash is worth less than present cash, and how much less depends on interest rates and perceived risk. When rates rise, the same future earnings are worth less today, and prices fall without a single thing changing at the company. This is why a Fed decision moves every stock at once.
Perceived risk. Uncertainty about whether those earnings arrive raises the return investors demand, which lowers what they'll pay now.
Flows that have nothing to do with the business. Index rebalancing, fund redemptions, tax-loss selling in December, a large holder liquidating for reasons of their own. Real price movement, no information content.
The part most explanations skip
Price is set at the margin, by whoever is actually trading, not by everyone who owns the stock.
A company with a billion shares outstanding might trade two million on a given day. That's one fifth of one percent of the ownership setting the price for all of it. The other 99.8% of holders did nothing and had no say.
The price reflects the opinion of the small minority who felt strongly enough to act today, not the considered view of everyone who owns the business.
This is why prices can move violently on modest news, and why a forced seller who has to liquidate can drag a price far below anything justified by the business. Understand this and a lot of otherwise baffling market behavior stops being baffling.
Price is not value
Here's where this connects to everything else.
A company has an intrinsic value: the present value of all the cash it will generate from now until it stops existing. That number is not on the ticker. The ticker shows the last transaction.
Sometimes the two are close. Often they aren't. The entire discipline of fundamental analysis exists to estimate the value carefully enough that you can tell which situation you're in.
If price always equaled value, there would be nothing to do but buy an index fund. The reason to do the work is that the two drift apart, and they drift apart because price is set by whoever happened to be trading today, under whatever pressures they were under.
What about market cap
Market capitalization is share price multiplied by shares outstanding, and it's often described as what a company is worth. It isn't quite.
It's what the market is currently pricing the equity at, extrapolated from that last marginal trade across every share. Nobody could actually buy the whole company at that price; attempting it would move the price enormously. Market cap is a useful comparison tool and a poor statement of worth.
What this means for how you behave
Two practical consequences.
First, a falling price is not by itself information about the business. It's information that sellers outnumbered buyers at recent prices. Sometimes that's because something is genuinely wrong, in which case your job is to find out what. Sometimes it's a fund unwinding a position. The price alone doesn't distinguish them, and treating a decline as evidence is how investors talk themselves out of good businesses.
Second, the reverse is more dangerous. A rising price feels like confirmation that you were right. It's the same thing in the other direction: buyers outnumbered sellers. It is not proof of anything about the business, and a thesis that gets its validation from the price chart isn't a thesis.
What to do with this
Pick a stock you own that moved more than 3% on a day recently. Find out what actually happened: an earnings release, a sector move, an analyst note, an index change, or nothing identifiable at all.
That last category is the useful one. If you can't find a reason, the honest conclusion is that supply and demand shifted among a small number of traders for reasons you'll never know, and your valuation of the business should not change at all.
Getting comfortable with that is most of the discipline.
Price versus value is where Book One starts.
Book One teaches you to estimate what a business is worth so you can tell when the price has drifted away from it: the three financial statements, the ratios that separate quality from a cheap multiple, and the growth-at-a-reasonable-price screen built on top of them.