The times I’ve seen this, it’s because I have uncommitted changes against the current HEAD.
First things first, Stash any changes on your current HEAD or “revert” to the prior commit (discard the changes).
Then, with no uncommitted changes active, you should be able to switch to the checkout you wish. If you’re going to edit anything, it’s better to create a new (local) branch at the commit than to check it out. You can then commit these changes against the local branch and switch without issues.
Git will always complain if you try to leave changes on the table.