As per your scenario and setup, the ID token generated during both the attempts at login and edit profile should be ideally cached as you are using the ‘loginPopup’ method for credential validation.
The ‘loginPopup’ method opens a pop-up window with the Microsoft identity platform endpoint to prompt and validate the user's credentials. After a successful sign-in, msal.js initiates the authorization code flow. At this point, a PKCE-protected authorization code is sent to the CORS-protected token endpoint and is exchanged for tokens. An ID token, access token, and refresh token are received by your application and processed by msal.js, and the information contained in the tokens is cached. When you acquire an access token using the Microsoft Authentication Library, the token is cached. When the application needs a token, it should first call the ‘AcquireTokenSilent’ method to verify if an acceptable token is in the cache. Clearing the cache is achieved by removing the accounts from the cache. This does not remove the session cookie, which is in the browser, though. MSAL maintains a token cache (or two caches for confidential client applications) and caches a token after it's been acquired. In many cases, attempting to silently get a token will acquire another token with more scopes based on a token in the cache. It's also capable of refreshing a token when it's getting close to expiration (as the token cache also contains a refresh token). Please refer the authorization code flow diagram below for better understanding: -
Authentication Protocol Diagram
Thus, you might need to check whether cache or cookie access is enabled in your browser or not, and if its enabled, then you might need to clear the cache in your browser so that tokens are managed accordingly.
Please find the below documentation links for your reference: -
https://learn.microsoft.com/en-us/azure/active-directory/develop/msal-net-clear-token-cache
https://learn.microsoft.com/en-us/azure/active-directory/develop/msal-acquire-cache-tokens
https://learn.microsoft.com/en-us/azure/active-directory/develop/tutorial-v2-react
https://learn.microsoft.com/en-us/azure/active-directory/develop/v2-oauth2-auth-code-flow
Thanking you,