A company buys back its stock if it thinks the stock is underpriced. Otherwise when “you have more money than you know what to with” you give it to your shareholders via a dividend. A concept mostly forgotten by tech companies.
Buybacks are the preferred method of RETURNING CASH to shareholders, because dividends historically have been sticky. Buybacks are flexible.
Buybacks are also done to optimise the debt ratio, to minimise the firms cost of capital and thereby maximizing firm value.