I'm confused! Please explain!

First, use the fact that [tex]\tan x[/tex] is [tex]\pi[/tex]-periodic. This means [tex]\tan(x+\pi)=\tan x[/tex] for all [tex]x[/tex], and in particular
[tex]\tan\dfrac{9\pi}8=\tan\left(\dfrac\pi8+\pi\right)=\tan\dfrac\pi8[/tex]
Now, recall the half-angle identities,
[tex]\sin^2\dfrac x2=\dfrac{1-\cos x}2[/tex]
[tex]\cos^2\dfrac x2=\dfrac{1+\cos x}2[/tex]
[tex]\implies\tan^2\dfrac x2=\dfrac{\sin^2\frac x2}{\cos^2\frac x2}=\dfrac{1-\cos x}{1+\cos x}[/tex]
When we take the square root, we get two possible values, but we know [tex]\tan x>0[/tex] for [tex]0<x<\dfrac\pi2[/tex], so we know to take the positive square root:
[tex]\tan\dfrac x2=\sqrt{\dfrac{1-\cos x}{1+\cos x}}[/tex]
So we have
[tex]\tan\dfrac\pi8=\sqrt{\dfrac{1-\cos\frac\pi4}{1+\cos\frac\pi4}}=\sqrt{\dfrac{1-\frac1{\sqrt2}}{1+\frac1{\sqrt2}}}=\sqrt{(\sqrt2-1)^2}[/tex]
[tex]\boxed{\tan\dfrac\pi8=\sqrt2-1}[/tex]