Stocks are sold as shares, which represent partial ownership of a company. Corporations, when publicly traded, divide their capital by their total number of shares in the market. Thus, each share’s value is equal to the percent of capital that it represents. As the corporation’s overall capital grows, so does the value of each share. Thus, when you own shares in a company, if the company profits then you also profit.
Stock prices vary over time. As with any economic asset, when demand for a given stock increases, its price will also increase; this works inversely with supply. Stock prices shift with supply and demand as a means of maintaining equilibrium within the market. If there are more buyers than sellers (high demand) for the stock then the price will rise. If the price is higher, more sellers will enter the market and more buyers will exit the market. This creates the equilibrium. It can also change based on analysts’ forecasts regarding the company’s future.