Why do companies buy back their own shares even when they know the shares are overpriced? The following graphic from Bloomberg should help explain the reason. It shows how the compensation for IBM's CEO, Ginni Rommetty, is broken down.
When a company buys back their shares they are removing the number of total outstanding shares. Reducing the supply of shares raises the earnings for each share that is remaining.
Think of it like this; a company goes public and issues 10 shares of stock to investors. The company is earning $10 per year, meaning they are earning $1 per share. If the company decides they would like to buy back 5 shares there are only 5 remaining shares outstanding. The $10 in annual earnings now equals $2 per share with no improvement in earnings. The portion of the CEO's pay tied to earnings per share has now doubled. Everybody wins, until the market goes down, but fortunately that will never happen again.
For more see U.S. Stocks: Something Wicked This Way Comes