There are two possible ways. The first way is when a stock you own appreciates in value - that is, when people who want to buy the stock decide that a share is worth more than you paid for it. They might decide that because the company that issued the stock has earnings that are improving, for example.
If you hang onto a stock that has gone up in value, you have what's known as unrealized gains. Only when you sell the stock you can lock in your gains. Since stock prices fluctuate constantly when the market is open, you never really know how much you're going to make until you sell.
The second way is when the company that owns the stock issues dividends - a payout that companies sometimes make to shareholders.