Classically, this is the behavior of teenagers - in extreme cases classified as "oppositional defiance disorder" - but even adults experience this kind of inherent oppositional reaction when we feel our independence is being challenged.
In psychology, this is known as "psychological reactance theory". From Psycholopedia:
Psychological reactance is an aversive affective reaction in response to regulations or impositions that impinge on freedom and autonomy (Brehm, 1966, 1972, Brehm & Brehm, 1981; Wicklund, 1974). This reaction is especially common when individuals feel obliged to adopt a particular opinion or engage in a specific behavior.
Specifically, a perceived diminution in freedom ignites an emotional state, called psychological reactance, that elicits behaviors intended to restore this autonomy (Brehm, 1966, 1972, Brehm & Brehm, 1981; Wicklund, 1974). Reactance, for example, often encourages individuals to espouse an opinion that opposes the belief or attitude they were encouraged, or even coerced, to adopt. As a consequence, reactance often augments resistance to persuasion (Brehm & Brehm, 1981). Reactance was proposed to explain many common examples of resistance in society, such as the adverse effects of prohibition.
Yes, this is a real, traceable, verified concept: an individual is more likely to be confrontational when s/he perceives that his or her freedoms are being impinged. It doesn't matter why or whether or not they agree with the underlying principles: merely the act of feeling confined, physically or mentally, induces a basic "fight or flight" syndrome that comes out as oppositional defiance.
Keep this in mind both as you watch your own behavior and as you watch how others respond to you. If you know you are predisposed to a negative response in certain situations, you can have mitigate that response to some degree and prevent yourself from getting into confrontations you don't necessarily want to have. You can also strive to prevent others from feeling the same kind of confinement and, thus, hopefully reduce their tendency to be confrontational in return.
(Sorry for the long lag between posts; I'll try to get at least one a month up.)