Both David Yappeter's answer and Juan Cruz Borssotto's answer are good. The one thing I would add is this, building on Juan's point that a branch needs a commit to exist:
Git's git init creates a new, totally empty repository (when used the way you used it: sometimes it just "reinitializes" an existing repository, which is kind of a useless mode and I wish it required a flag for this or something).
An empty repository has no commits, so it cannot have any branches.
And yet, you're still "on" some branch.
This means you can be "on" a branch that does not exist. That's kind of a special case: it's not a normal way to work at all. It's required in this new, totally-empty repository.
When you are in this state, the next commit you make (which is now the first and only commit in this otherwise-empty repository) creates the branch name. The branch name that Git creates at this time is the name of the non-existent branch you're on. That cause the branch to come into existence, simultaneously with creating the commit.
So that first commit both creates the branch, and creates the commit that's the only commit on the branch, even though you're on the branch that didn't exist. It's almost a sort of a big-bang create-the-universe event. It only happens once in each universe, er, repository.1 Once the branch exists, the normal operations—like "rename this branch"—all work.2
Because of this particular bit of weirdness, some web hosting sites will make one initial commit for you in a repository you create with their create a new repository web clicky button. Specifically, GitHub do this by default. That gets you out of this weird mode and means you don't have to learn to deal with the weirdness. Some people really like this (the GitHub folks in particular!).
1Technically, you can re-create this weird mode in a non-empty repository, using git checkout --orphan or git swtich --orphan. That's not something most people normally want to do, ever. This feature was new in Git version 1.7.2; before that, you had to reach deep into Git's guts to do the trick.
2A need to rename the as-yet-uncreated branch was not foreseen, so for a long time there was no official way to do this. Once people started renaming master to main, the need became obvious, and the Git folks released Git version 2.30 to make that easy.