Companies can cancel (“retire”) shares which they bought back, but they don’t have to - they can keep the shares in what, according to Wikipedia, is called treasury stock in the US and treasury shares in the UK.
There are various reasons why a company may wish not to cancel shares which it bought back. It may want to keep them for future re-issuance, for instance. Sometimes, companies don’t even intend to keep shares which they bought back for an extended period - they could be engaging in market making: In small companies where there is not much trade going on (in other words, where the market in shares is “illiquid”), the spreads between bid and ask offers may be quite wide - something investors hate, because it affects their chances to sell the shares at a reasonable price when they want to. In such instances, companies can continuously buy and sell their own shares to narrow the spread, and they can keep repurchased shares to have something to sell the next day.