If you're trying to clone a repo without logging in, the below will prompt you for a password
git clone https://username@github.com/username/repository.git
If you check your gitconfig file, programfiles->git->etc->gitconfig
You could notice the credential helper set to manager-core
You can be accessing/cloning multiple GitHub accounts from your local. Using a username lets it use/cache the respective account credentials.

In CI/CD pipelines when we configure the first step where the code gets checked out from the remote repository, we have username and password picked from the credential manager/helper
git pull https://${GIT_USERNAME}:${GIT_PASSWORD}@github.myorg.com/myrepo.git
More or less, this is what happens in our system locally, where the credentials are picked from the cache based on the username.
In the case of ssh, when you specify git@github.com:username/repo.git
, it simply tells git that the user is git itself and that it should go get the credentials (public key) from the ssh-agent for the host github.com.
You could also set the username for a specific host
[credential "https://example.com"]
username = foo
Ref:- http://git-scm.com/docs/gitcredentials
Ref:- https://git-scm.com/book/en/v2/Git-Tools-Credential-Storage