It is said that supply and demand determine the price of stocks but there must be other factors. For example when a company is about to expand the price will usually go up. Why? (The answer that it is because more people will buy the stock is wrong because there must be a reason for people to buy that stock that isnt people are buying the stock.)
There's a bit of slackness in the phrasing of the question- you may have collected ideas or terms from informal sources (which is normal).
Supply and demand refer to functions which can be rearranged to get either price as an output or quantity.
Quantity Supplied = f(P, etc.)
Quantity Demanded = f'(P, etc.)
Included in that etc. is "Anticipation of future prices", which is the major driver of stock purchases. The various other drivers are here: When do supply and demand curves shift?
Especially for stock prices, it is exclusively demand and supply that drives them - that's how stock exchanges work. The quoted price is the price at which sellers want to sell and buyers want to buy.
The real question here is: what drives demand? In your example, if markets expect that a company's expansion will increase the value of that company, than that expectation will drive up demand, so the price goes up.
Btw, stock market dynamics are not just driven by fundamentals. If you are good at guessing what the majority of market participants expect, you would do exactly what you suggest cant be a driver, namely buy the stock because you expect others will want to buy it. You obviously want to do that before others become interested. Many short-term strategies are based on such expected market behavior.