Actually you are asking little bit different question in your title and then in your question. There is difference between asking why stock market always grows and why individual companies’ stock grow. In fact in case of individual companies you can see that many companies fail and their stock price gets wiped out despite the stock market always growing over time so those are fundamentally different questions but I will try to respond to both of them.
- What determines individual stock price? There are multiple stock pricing models but they more or less boil down to estimating what will be the future discounted return on your investment in one way or another. An example of a stock pricing model would be the Gordon’s growth model, where the stock price is given by:
Where $P$ is the price $D_0$ is the current dividend, g is the dividend growth rate and r is the required rate of return.
So the individual stock price can increase either due to higher dividend payments, higher expected growth rate of these dividends or lower required rate of return.
However, as mentioned before there is no reason to think or even expect for any individual company’s stock price to always increase in a long term. In fact you have a lot of companies that simply fail and their stock price becomes zero.
Also note the explanation above is little bit oversimplification because there are firms that don’t pay out dividends but they are still being valued and their stock price can grow, but I on purpose did not wanted to make my answer overtly technical and include some more complex models that can handle that as well, and generally the explanation is still valid one.
- How come that stock market tends to grow over time? This is because even though individual companies can and often do fail they are usually replaced by new and more efficient companies. In general thanks to economic growth, which depends on technological growth, growth of population, or even due to endogenous factors like human capital accumulation, firms are constantly getting more efficient and more productive meaning they can generate larger profits with less inputs and consequently also payout more of this profit as dividends. Firms that can’t adjust to technological change and deliver better products more efficiently will fail and be replaced by those companies that can. Recent famous examples would be Kodak or Nokia.
This being said if the economic progresses of humanity would be halted for whatever reason the stock market could start failing over time. For example in case of some apocalyptic scenario such as nuclear war. It might also happen that eventually human race would end up in some stagnant state when there would be no more future growth because we would reach a point where we can’t get any new technological progress or accumulate more human capital - but that does not seem to be probable any time soon.