Why do stock prices rise over time?
If a company's market cap is meant to represent the discounted cash flows in perpetuity at a given cost of capital and growth rate, why, on average, do stock prices rise over time? Wouldn't that only occur if the variables like cash flow or growth rates are consistently underestimated?
Your analysis is actually correct, in that cash flow and growth rates are constantly changing, and generally they are changing for the better. As a result, future cash flow increases at a faster rate than previously expected and the stock price is adjusted up due to these increasing cash flows. Because no one can predict the future, as new facts become apparent they changes the expectations of future cash flows.
This, of course, assumes we are looking at a company’s stock over the long-term. Short term the stock price can go all over the place due to news stories, investor emotions, political uncertainty, and other random factors. The reason cash flow and growth rates continually increase are numerous, but a few of the most common factors include:
Inflation
As general prices increase, the cash flow to a business for selling it's products will also increase. This of course does not provide a real return to the investor, but it is a component of the rise in stock prices.
Technology
The development of new technology allows companies to be more productive, increasing revenues and decreasing costs
Company growth
As a company becomes better known and sells more of their product, their cash flows increase beyond what was originally expected (this can be significantly impactful for small companies).
Population growth
As more people are in the economy, they buy more stuff, which increases company cash flows
New Markets
As other countries become wealthier, and as companies sell to those other countries, cash flows for international businesses increase.
New Products
The development of new products can have a dramatic impact on company sales. An example is how much Apple's future cash flows changed once the iPhone was invented.