Git is an amazing tool with terrible UX. It's very difficult to know what the right thing to do is and the mental model is a bit weird. For example, undoing an operation is another, new commit.
That is the option of last resort, when you have already pushed _and_ you cannot mess with the history anymore.
The other one being reseting your local branch to a previous commit and force pushing if needed.