Why does the use of the sign function work in this rotation formula?

Your $t$ appears to be the horizontal coordinate of the point before the rotation. So $t-a$ is the same but measured relative to $C$. So for points left of $C$ you get negative $t-a$, for points right of $C$ protective $t-a$.

Since $D$ is a distance, it is missing information about the orientation. $D$ and $A$ together give you a distance and an angle. But based on the fact that you are asking this question, I'm assuming that your $A$ is angle without orientation, i.e. only covers a range of $180°$. So you're dropping information which side you're going. That sign restores this information.

One alternative would be making the distance $D$ signed by multiplying the sign function into that. But that would be slightly artificial since in terms of the definition. So the more natural alternative would be making the angle cover a $360°$ rage. This is very similar to the use of atan2 instead of atan in many programming languages, which in turn reminds me of an answer of mine around how to compute such an angle.

So if your angle would have covered the whole range, the sign would not have been needed. But if your angle covers only half the circle, you need to provide more information.