Consider the following diagram.
I am told that $\cos 45^{\circ}$ = $\frac{1}{\sqrt 2}$. I understand this.
I am next told taught that $\cos 135^{\circ}$ = $\cos 45^{\circ}$ in 2nd quadrant. And finding $\cos 45^{\circ}$ in 2nd quadrant means $\frac{-1}{\sqrt 2}$.
I am puzzled - aren't we concerned about the actual length of the triangle? The magnitude so to speak. $-1$ is the x-coordinate, telling us where it falls on the xy plane. Why are we not just taking the length i.e. $\cos 135^{\circ} =\frac{1}{\sqrt 2}$.
I know the calculator gives different values, but I'd like to understand this.

The conventional definition in triangles requires the angle to be 0-90 degree. 135 > 90 such that the traditional way is not applicable. In the axes that you shown, you can simply see that the x axis is negative, which explains the negativity in the result.