There is really no reason to prohibit firms from buying back their own shares. It is a good way for firms to invest in themselves and it does not really hurt anyone.
At times, it is in a firm's best interests to buy back its shares of stock. By doing so, it can, for example, prevent outsiders from buying up enough shares to carry out a take over of the firm. In this way, buyback allows the firm to defend itself.
As another example, the firm can buy back shares in order to own more of itself. It might do this when it knows that it is going to prosper and it wants to keep more of the profit for itself.
This does not harm anyone because the people who sell the shares do so willingly. They are not forced to give up their shares. Therefore, it is a consensual agreement and there is no harm in doing it.