A dividend is a payment distributed by the company to shareholders, usually every 3 months. Many companies are not required to pay dividends to shareholders and so they will choose to reinvest it back into the company.
There are dividend reinvestment plans which automatically use the cash payment you’d usually get to buy more of the company’s stock.
Note: dividend payments reduce the price of the stock.
Collecting dividends is also no safer than selling down your portfolio, which is a common misconception. A non-reinvested dividend is literally a withdrawal from your portfolio, except you don’t have control over when it happens*.