How does an ATM actually work?
The machine handed you your money, and the cash inside it did not belong to your bank.
The ATM asks the network, the network asks your bank, and only then does cash move locally.
The conversation, in about two seconds
Insert the card and the machine reads the account details. Enter the PIN and it is encrypted immediately, inside the keypad hardware, so the machine never handles it in readable form.
The request travels to a switch, then to your bank, which checks the balance, daily limits and fraud signals, and answers. Only then do the shutters move.
Your account is debited at the moment of authorisation, which is why an ATM withdrawal shows instantly while a card purchase can take days. Nothing about the underlying settlement is faster. The debit simply happens at a different point.
Whose cash is that
This is the part almost nobody knows. If you are using another bank's machine, or an independent one in a shop, the notes came from that operator's own working capital. They have thousands of pounds sitting in a box in a wall, earning nothing, waiting for you.
When you withdraw, they have effectively lent you your own money on your bank's behalf. Your bank reimburses them through the network and pays an interchange fee for the service.
Which explains everything about ATM economics. The operator carries the cost of cash sitting idle, the armoured van that refills it, the rent, the insurance, and the machine. If the interchange does not cover that, they either add a surcharge to you or remove the machine. That is why free-to-use machines have been vanishing in market after market, fastest in exactly the places with the fewest alternatives.
Two fees, and they are different
The operator surcharge is charged by the machine's owner and must be disclosed on screen before you commit. You can walk away.
Your own bank's out-of-network fee appears later on your statement, and you cannot decline it once you have taken the cash.
Abroad, a third appears: the currency conversion. If the machine offers to charge you in your home currency, that is dynamic currency conversion, and declining it is almost always correct.
A vending machine stocked by a local shopkeeper with their own goods, which your supplier settles up for later. The shopkeeper is fronting the stock, and they need a reason to keep doing it.
Where you meet it
Every "this machine charges a fee, continue?" screen, every cash machine that disappeared from a high street, and every holiday withdrawal that cost more than you expected.
