Logging in does not change your connection to a site. It hands your browser a string to present on every later request, and almost everything about staying or not staying signed in follows from that.
The protocol a browser uses to fetch pages treats each request as if it were the first. The server receives a request, answers it, and keeps no memory of who asked. Logging in therefore cannot change the connection itself, because there is nothing durable there to change. What it does instead is give the browser a piece of identification to send back with every subsequent request.
That identification is normally a cookie: a small named value the server asks the browser to store and return on later requests to the same site. The general mechanism is described in Wikipedia's article on HTTP cookies. A session cookie does not contain your password. It usually holds a long random string that means nothing on its own but which the server recognises. Possession of that string is, for practical purposes, possession of the account.
There are two common designs, and the difference explains a lot of behaviour you have probably noticed.
This is why "sign out of all devices" is instant on some services and takes until the end of the day on others.
Many services issue a short-lived credential used for ordinary requests alongside a long-lived one whose only job is to obtain fresh short-lived ones quietly in the background. That split is why an app can keep you signed in for months yet still ask for your password the moment you try to change the email address on the account. The long credential proves it is the same browser; it does not prove a person is present.
Where one account opens several unrelated services, the pattern is single sign-on, covered in Wikipedia's article on single sign-on. One provider holds the session and vouches for you to the others. It removes a great deal of friction, and it concentrates the consequences: the provider account becomes the one worth protecting most carefully, which is the argument for putting your strongest credentials there, as in password managers and passkeys.
An attacker holding a live session cookie does not need the password and does not meet the second factor, because the session was created after both were satisfied. Taking over an existing session this way is session hijacking, described in Wikipedia's article on session hijacking. The defences are mostly invisible: the cookie travels only over an encrypted connection, the kind established by Wikipedia's article on Transport Layer Security, and is marked so that scripts on the page cannot read it. What is left to you is not pasting your credentials into a page you arrived at from a message, which is the subject of spotting a cloned website.