Why is anyone obliged to obey an authority?
To “oblige” someone means to compel him as a free and moral agent, to do something, i.e., to compel his will in the sense of making doing anything else, or refraining from doing what is obligatory, shall entail a disorder of the will. “Hoc est obligare, scilicet astringere voluntatem, ut non possit sine deformitatis nocumento in aliud tendere.” (St. Thomas Aquinas, In II Sent., d. 39, q. 3, a. 3) The will retains the power to choose something else, but to do so would be bad.
The authority of conscience and the truth
So, for example, the interior judgment of conscience obliges the will, when a person judges doing something to be a good of such a sort, that not doing it is bad. (In II Sent., d. 39, q. 3, a. 3; Summa Theologiae (ST) I-II, 19:5). And that is true even if their judgment is, objectively, incorrect. The person is not, however, obliged by their judgment itself, as though their fundamental obligation were to follow their own judgment, but by the good, which he by that judgment holds to be an indispensable good. (In II Sent. d. 39, q. 3, a. 3 ad 3; ST I-II, 19:5 ad 1).
The most interior authority one is obliged to obey is therefore one’s conscience, while the ultimate authority is the ultimate truth about the good that we naturally love and seek.
External authorities
Why is anyone obliged by any other authority, besides the dictate of his conscience and the truth about the good?
We may be obliged to follow an authority because we need specific guidance in order to attain the good, so that our guide is an authority for us, which we are obliged to follow. For example, if I have been stricken with the plague, and desire (and perhaps am obliged) to regain my health, I may be obliged to submit myself to medical authority and follow its prescriptions. And this obligation holds, regardless of whether the "medical authority" is realized in a doctor whom I trust implicitly, or exists in a diffuse manner in medical practitioners and scientists taken as a group and comes to me through their general consensus.
Moral authority
This type of authority is often termed moral authority, rooted in the truth held and taught by the authority in question, whether that truth be medical, physical, philosophical or religious. For the Catholic, the Fathers, doctors and saints are authorities.
As our obligation to respect moral authority is not rooted in a specific responsibility for us on the part of such authority to determine the good we ought to seek, but in the truth of the good itself together with their capacity to communicate that truth, we are not bound by obedience, but by prudence to respect and sometimes to follow moral authorities.
If I need to repair my car, and my next-door neighbor, an expert mechanic who has a great deal of experience with repairing exactly that kind of car, examines it and tells me what I need to do, it is in all probability foolhardy to reject the recommendation in favor of the first Youtube video I find of someone who kind of sounds like he knows what is talking about.
In the majority of cases, moral authorities are not absolutely binding on us, and we are morally free not to follow them, though we might be imprudent to scorn them altogether.
Moral authority in the Church
Within in the Church, the Fathers, the doctors and the saints are moral authorities, as are the tradition and custom of the Church in the measure that they are treated by the Church as a kind of common law. “The custom (consuetudo) of the Church has very great authority and ought to be jealously observed in all things” (ST II-II, q. 10, a. 12)
In the measure that a given authority infallibly (e.g., Sacred Scripture and Sacred Tradition as modes in which God speaks to us) teaches something we are obliged to know or accept, its moral authority is absolutely binding, at least in principle. In practice, we may have difficulty in discerning what is infallibly taught by that which we accept as a bearer of revealed truth. (See ST II-II q. 11, a. 2 ad 3, where St. Thomas explains why not every error about matters of revealed truth is a heresy.) Catholics accept the authority of the Church in interpreting Scripture, and the authority of the pope in defining and articulating the teaching of the Church, but none of these authorities can be received by us unconditionally without any discernment on our part. We might have misunderstood what Scripture is saying or what the Church taught, or a given ecclesial or papal teaching might not adequately represent and expound the divine revelation to which it has the vocation and responsibility to witness, but in some manner distort it. (Though a look at church history supports this last claim, the claim may have been fairly controversial a few years ago in some Catholic circles, but I believe the experience of Pope Francis’s papacy has largely changed that; the point may however still not be adequately accounted for in the Church’s own account of the obedience due to the Magisterium, see Donum veritatis 24, which explicitly only allows theologians to withhold assent to particular magisterial interventions that appear to them to be wrong or harmful).