Four moves for the next ten minutes, and the two weeks after, not a general essay on retention.
Most counter-offers fail, even the ones that get accepted. Money alone rarely fixes whatever made someone start looking in the first place, it just delays the departure by a few months. Before you counter, ask yourself honestly: if they say yes, has anything actually changed, or have you just bought time? If the answer is money was genuinely the only issue, a real counter can work. If it wasn't, a raise without addressing the real cause usually just moves the resignation date.
"Thank you for telling me directly, I know that's not always easy. Before we get into logistics, is there anything about the role or the team that, if it were different, would have changed this? I want to ask once, honestly, not to talk you out of it if your mind's made up."
HR usually runs a formal exit interview, but the conversation you have as their manager gets more honest answers, if you ask well and don't get defensive. Ask what made them start looking, not just what made them say yes to the new offer, those are frequently different answers. Ask what you personally could have done differently, and actually sit with the answer instead of explaining it away. The goal isn't to win the conversation, it's to learn something that helps you keep the next person.