I am trying to understand finding the joint angles to a robot arm and I am reading this tutorial on a website and either I am really dense or it is wrong.
The $5^{th}$ picture from the top where the author starts to label angles for law of cosines, he previously states that $\angle A_1$ is split into $D_1$ and $D_2$, and then he applies law of cosines but it looks more like the Pythagoras Theorem.

He is saying that angle $D_1^2 = X^2 + Y^2$ which I didn't understand. He has two unknowns, side $C$ and $\angle c$, so how does he solve for law of cosines?

The figure is nonsense. As you say, the Pythagorean theorem involves side lengths, not angles. The correct way to compute D1 is via arctangent (as the author does do later in the code).