Good people do bad things because they normally do good things. This is known as moral licensing or self-licensing. They do bad things because they decide that they deserve something as they have been good.
when an action is morally ambiguous your history of doing good things can make you feel like you can cut yourself some slack and grant yourself an exception. Moral licensing can undermine our ability to meet our goals.