There would never be a need for you to return the money.
A legitimate lender is perfectly capable of pulling back the payment on their own without any of your help.
Now you know how companies will often text you a one-time-use authentication code, typically in TXT to your cell phone. When linking a bank account, they will typically do the same thing by sending two "penny deposits" to your account. For instance they might send an 8 cent and 43 cent deposit to your account. They then demand these two numbers as authentication to confirm you control the account. Once that's done, they snap back the two deposits - they are not yours to keep.
One scam: "accidentally" send you too much money.
Then the person, having gained your confidence, will say they made a terrible mistake by fat-fingering the wrong amount. Then, they will claim they cannot pull the money back (total lies) and will manipulate you into returning the money via some other method such as Cryptocurrency, purchasing gift cards, Zelle, Western Union or some other irreversible method.
Then they will actually pull the money back, and keep the crypto, Western Union or whatever you sent them. You are left holding the bag.
Or the money they "sent you" never existed
This scam involves convincing you to use a "screen sharing" app which actually gives them remote control of your PC. They have you log into your bank account normally. Then, out of your sight, they go into developer console on the web browser you are using, and alter the HTML code so it shows a deposit that didn't actually happen. Then they say "oh look, it refreshed, there is our deposit indeed, just as I told you!"
Again they claim they made a mistake and you need to send them the money back via some other method such as Bitcoin etc. because they can't pull it back, always a lie.
And in this scam they get to see your bank account with their own eyes, so they know how bug of a "mark" you are and how much effort they should put into scamming you.
But they're always coming up with new scams
The common ground is they over-deposited and you need to send some back.
Or, they are trying to convince your bank to authorize them to take arbitrary withdrawals from your account.