Share buybacks typically happen because a company believes its market shares are undervalued.
By repurchasing some of the shares, the company decreases the supply of shares on the market. Then, as demand for shares increases, the value of any remaining shares raises as well. In turn, this brings shareholders more earnings per share.
Share buybacks are also a way to deliver profits to shareholders since companies typically buy the shares back at a premium price. In this case, the company can also benefit from avoiding the taxes that typically apply to dividend payments (only paying direct tax on the sale share).