When you check out a branch or commit with git, two things happen: git changes the files in the repository folder, and changes the file that tells it what is currently checked out. In git terms, it changes what HEAD points to. In practical terms, it updates the .git/HEAD text file to contain a different reference.
But these two operations can be done separate from one another, so that while the files correspond to one commit, git thinks that the HEAD commit is another one.