Prevent Redirect to My Account After Login
To prevent the user from being redirected back to the My Account page during login on Magento 2, and to let them stay on the same page they were on before logging in:
- Navigate to Stores -> Configuration -> Customers -> Customer Configuration -> Login Options.
- Disable the "Redirect Customer to Account Dashboard after Logging in" setting.