Some companies cancel the stock, some don't. Apple cancels it. Berkshire holds all the shares they have repurchased as treasury stock. They could easily use it as merger consideration in the future if they desired. The treasury stock is not outstanding and doesn't get voted by management. The other variation is the GAAP "treasury stock" at Biglari Holdings, where the company indirectly owns several hundred million dollars of its own shares through an LP investment, where management does vote the shares but they are eliminated from the GAAP financial statements as look-through treasury stock. This unusual arrangement causes many market participants to incorrectly compare the market cap using one share count to the published balance sheet.
If you leave the balance sheet entry for Treasury stock (at cost) it can provide an easy to judge record of accumulated share repurchases over the years. If repurchases flip shareholders equity negative it can make the relationship more apparent at a glance.
Apple, for instance, will likely flip to negative shareholders equity some time in the next few years. They publish a separate document that shows what Berkshire's 'Treasury stock, at cost' line item conveys -
https://s2.q4cdn.com/470004039/files/doc_earnings/2024/q4/generic/Q4-24-Return-of-Capital-Timeline.pdf