Obviously : some other process is doing something to your git repository.
If your repo is placed in a synced directory, for example (Onedrive, Google cloud, Dropbox ...), since all your git's state is stored in files, an automatic update of the .git/
folder could (if done in the wrong direction) move back info like the checked out branch, or the stored files ...
If your repo is placed in a shared folder, someone else running actions would also modify what you see.
If a cron job, or a hook triggers some action on your repo, it could switch your active branch back to master.
etc ...