The relation that you write as
$$
\tan x=\frac{\text{opposite}}{\text{adjacent}}
$$
only holds for acute angles and was, of course, the original definition of the tangent, in times when just positive numbers were considered. Since, for acute angles we have
$$
\frac{\text{opposite}}{\text{adjacent}}=
\frac{\text{opposite}}{\text{hypothenuse}}\cdot
\frac{\text{hypothenuse}}{\text{adjacent}}=
\sin x\cdot \frac{1}{\cos x}=\frac{\sin x}{\cos x}
$$
this relation has been taken as the definition of the tangent function also for any angle $x$ such that $\cos x\ne0$.
So, while the “opposite/adjacent” definition is handy for doing computations on triangles, the $“\sin x/\cos x”$ definition is better for analytic computations involving trigonometric functions. They agree for acute angles $x$ and that's the important point to note.