This is the urge to do the opposite of what someone wants you to do out of a need to resist a perceived attempt to constrain your freedom of choice. It is a form of rebellion against authority.
As you might imagine, reactance is common among teenagers. “Reverse psychology” is form of reactance that works particularly well on children. Just tell them to do the opposite of what you really want, and they will rebel and actually end up doing what you want. Sometimes.