Why is moving average cost recomputed when sales is made?

I was looking at the stock ledger of an item and how its moving average cost changes. It makes sense for the cost to be updated when a purchase is made or items are removed from stock due to expiry etc… But once the average cost is for items is decided why does it change when a few of the items are sold?

It changes because available quantity in stock changes. You can check a very good blog link which has more details.