If I give a dividend, each shareholder now has 100 shares priced at $99 (assuming the typical price drop for the dividend), and $1 cash.
If I buy back 1 share for $100, now one ex-shareholder has $100 in cash, and 99 other shareholders have 1 share valued at $100.
In each case, the company has $100 less dollars, and its market cap dropped from $10,000 to $9,900. But the stock price is higher ($100) in the case of buybacks than in the case of dividends ($99).