Apple has plowed over $500 billion into stock buybacks since 2012 — more than Visa, JPMorgan, or Exxon are worth::Only eight companies in the S&P 500 have larger market values than Apple's outlay on share repurchases over the last decade.
It's usually done to basically pay to increase companies own stock price. They often do it because CEO and executive pay is based on achieving certain goals such as stock price. However, every penny thrown at investors in a buy back is money that could have been used to weather a downturn, or increase employee pay or simply reinvested in the company itself. This often leads to companies then requiring government bailouts to continue functioning when say a global pandemic hits. The Plain Bagel has more detailed video on the ups and downs of stock buybacks on YouTube.
Why? It's a perfectly reasonable thing to do. The company sold stock to raise money. No reason they shouldn't be able to buy back the stock they sold with the money they made.
They didn’t sell stock to raise money to buy their stock, that doesn't make sense. They sell stock when they feel they need cash and/or they think they are fair/over valued. They buy stock when they have excess cash and/or feel they are undervalued. They also have to disclose both sales and purchases beforehand.