At the very lowest level, it could be gut feelings from a potential buyer. They see electric cars more frequently, combustion engines going out of fashion, and simply wonder "Hey, why does that [electric car company] trade so low, when they'll probably be market leaders in 5/10/15 years?", or conversely, "Hey, why does that [petroleum] company trade so high, oil prices are shot, and the industry will lose relevance in 10/20/30 years"
On a higher level, some potential buyer will look at the companies financial statements, and figure out if the share price is too high / low for how the company is performing, from a financial standpoint. This is called "fundamental analysis", and you can easily find step-by-step analysis reports of such on various companies.
But the market is one big hodgepodge of beliefs, with probably thousands of different rationales behind their prices, and motives for sales / purchases.
How does this work if a company doesn't pay out dividends? There's no investment to return unless someone buys from you at the same or higher price... right?