I had the same problem with one of the biggest french bank.
I saw an important withdrawal on my account in a city where I wasn't. I called my bank and I explained the situation. They told me I'll get the money back in one day. I asked if I should change my credit card in case it was hacked, they told me calmy it was just an error on their part because another client had the same last name. I just couldn't believe it.
About 20 years ago on a Saturday I was shopping for a new washer and dryer for a new house. I gave the cashier my Visa card (from my credit union) and was subsequently told that I was over my credit limit. (At the time that card had a $20k limit and no balance.) I used a different card and waited until Monday to contact my CU. They told me I had requested a balance transfer, but when I pressed them they realized that it was a different customer with a similar name (who was overdrawn on all accounts). Somehow the CU clerk decided to use my account because it had enough credit available to complete the request.
I closed all of my accounts at that CU shortly thereafter. (It was actually after a second fiasco where they failed to pay my property tax, but still withdrew the money from my account.)
Ultimately, that's what happens when it's a human that gets the final sign off. You can put all the control and checks in place you need, either the human validates the case and events like this happens, or the computer has final authority and people complain about lacking human touch and comprehension and "they know me for decades but I can't get 20 euros out without several proof of identity".
I'm not sure which way I would consider best. I guess as long as banks are stepping up to their errors and fixing them immediately as in your case, I prefer that.
I had something like that happen with a closed credit card. I don't know what the mistake was, but I suddenly had a $6,000 statement credit due to a misapplied payment. When I called to tell them, they offered to send me a check! After I declined the misbegotten windfall, they put in a little effort and figured out where it was supposed to go.
In many contries, if they send you a check, even in error, you are allowed to cash it if you choose. I recommend consulting a lawyer, and keeping it in a seperate account for a while before spending. Local laws vary widely, some jurisdicitions will disagree. Consider local and national laws as they may appy. Ianal.
Regardless, it wouldn't have been right to keep the money. Especially since doing so probably would have caused problems for the person who made the misrouted payment.
I've actually never heard a story end that way. Pretty much all of them involve the bank convincing a court that a reasonable person would have recognized the error, and therefore you need to pay up.