Firms will generally guy their stock back from shareholders if they feel that their stock is undervalued. This has two effects.
First, it can allow the firm to own more equity in itself. If the shares are not retired, the company simply holds on to them. By doing so, they are investing in themselves. This shows that they believe that their company is worth more than the stock price would indicate.
Second, it can raise the price of the remaining shares. If the firm retires the shares, this raises the firm's earning per share ratio. This is likely to make the firm's share price rise.
There are other possible reasons to buy back shares, but the main one is to take advantage of a share price that is lower than it ought to be.