The people who are buying and selling the stock are the ones who decide what the value of the stock is. And of course people are never perfect. They make mistakes. Sometimes they overvalue a stock because they are aping each other and buying at ever higher prices just because many other people are buying.
The opposite can happen in selling, which results in undervaluing.
But people selling too much or buying too much are only indirect signs of possible value misalignment. If you want to know directly the value of a company, then you need to look at the value of its assets, its income, and its prospect for growth in the future. Subtract the company’s debt from its total worth. And the result will be your estimate of the company’s worth.
And then you can calculate the worth of the company in terms of its stock price by multiplying the total number of outstanding shares by the price of each share.
If your estimated worth is less than the value calculated from the stock price. Then this company is overvalued. And if your estimate is bigger than the calculated value, the company is undervalued.