Please verify your TenantId configuration, as the error suggests that a fixed TenantId might be used for the authentication request.
https://learn.microsoft.com/en-us/entra/identity-platform/reference-error-codes
InvalidGrantRedeemAgainstWrongTenant - Provided Authorization Code is intended to use against other tenant, thus rejected. OAuth2 Authorization Code must be redeemed against same tenant it was acquired for (/common or /{tenant-ID} as appropriate)