Namely, with cash/bank transfers, it's a common scam for a stranger to send you money and then say it's a mistake and ask you to send it back. Then, they cancel that transaction with the bank. You'll see the original balance reversed by the bank but legally speaking, because you sent them the money back, you authorized that transaction and cannot get your money back.
If someone accidentally sends you money via Paypal, Venmo, Apple Pay, etc etc, don't send it back to them, that's for them and their bank to deal with.