This can occur if the resource was initially accessed with another account or the cached credentials are corrupt. This is more likely to occur if accessing another organization's SharePoint or Teams site as an external user.
SharePoint and Teams web version
Teams - installed app