The good news is that this happens even to professional cashiers. But rarely. But it does happen. And that's why there are rituals for handing out money.
Count the money, transferring it from hand to the table or from one hand to the other, TWICE. If the amount is the same both times, give it to the recipient.
And, of course, recount the money when receiving it.
Although you say later that you put it in the cash register... Well, then, never mind, I was wrong.