Note that GitHub completely ignores your configured
user.name. It uses only the authentication you send them.
When you push with SSH (
ssh://firstname.lastname@example.org/path/to/repo.git), the authentication you send is your SSH key. The details of how this are stored are somewhat OS-dependent.
When you push with HTTPS (
https://github.com/path/to/repo.git), you will generally have to enter a user name and password. These make up the authentication you send. If you are not being prompted to enter a user name and password, you might want to check any cached or stored authentication credentials. The details are, as before, OS-dependent.
Git does have a few built-in "credential helpers" for HTTPS. The default one simply asks for user name and password every time. The "cache" helper stores them in memory and times them out, and the "store" helper which is not secure stores them as plain-text files, meaning anyone with access to your files can find your password. See https://git-scm.com/book/en/v2/Git-Tools-Credential-Storage for details on these.
You can install additional helpers, and some come with some OSes, that do store authentications more permanently, but also store them reasonably securely, the same way SSH does.
Existing StackOverflow post git credential.helper=cache never forgets the password? has additional information on setting and clearing credential helpers (although the specific questions about why the cache timeout was not working, way back in Git 126.96.36.199, are not answered there).