When cosine is supplied with an imaginary number, it becomes a hyperbolic cosine:
$$\cos(ix) = \cosh(x)$$
No factor of $i$ on the right -- it is a straight-up, hyperbolic cosine.
Thus when you take $\cos(-i \log(2 + \sqrt{3}))$ to obtain 2, this is equivalent to taking $\cosh(-\log(2 + \sqrt{3}))$, which also equals $\cosh(\log(2 + \sqrt{3}))$ since $\cos$ and $\cosh$ are even.
The circular trigonometric functions $\cos(x)$ and $\sin(x)$ are usually interpreted in terms of a triangle, but the better way to interpret them is they parameterize the circle by arc length, that is, $(\cos(t), \sin(t))$ traverses the circle at constant speed as $t$ advances.
Now, if we are considering complex inputs, these coordinates become complex numbers and the resulting shape is now a sheet in 4 dimensions, not a curve in 2. Taking imaginary "angles" into the function takes us onto another part of this 4-dimensional figure which looks like a unit hyperbola, not a circle, and the interpretation of $\cosh(\log(2 + \sqrt{3}))$ geometrically is it is the $x$-coordinate of a point on the unit hyperbola when you have traveled distance $\log(2 + \sqrt{3})$ of arc length along it, and that moving this distance thus leaves you at an $x$-coordinate of 2. I found this figure on the web which illustrates it.

(Image public domain from: https://en.wikipedia.org/wiki/File:Hyperbolic_functions-2.svg)