Two cashiers, one remaining item
Two cashiers check stock at nearly the same moment. Both see one item left and sell it. Each sale looked valid alone, but the shop has now sold the same item twice.
In software, this can happen when separate tasks read and change the same data without coordinating. The bug can be hard to repeat because small timing changes affect what happens.
Keep the check and change together
To prevent this, software must coordinate the stock check and sale so two sales cannot both claim the last item. Teams may use database transactions with rules that block conflicting sales, or controls such as locks and queues.