Exactly?
Imagine there is no stock market yet...
there is a business that is positioned to grow but are limited on working capital. they decide to offer shares in their business for anyone willing to pay a certain amount per share. When the company has enough shares sold and have the working capital they need, they will then start growing and becoming more profitable. The value of the company goes up making the shares more valuable. That's when a share holder can sell their shares or a portion of them to make a profit. However, if they choose to hold onto them, they will be paid a dividend... a percentage of the profits from the company they own the shares in.
A stock market or equity market is the aggregation of buyers and sellers (a loose network of economic transactions, not a physical facility or discrete entity) of stocks (shares); these are securities listed on a stock exchange as well as those only traded privately.