Let me propose a somewhat geometric explanation. I hope you are familiar a bit with vectors.
Assume you have the standard orthonormal coordinate system $O\overrightarrow{e}_1\overrightarrow{e}_2$ (usually called the $x,y$ coordinate system, but here, we cannot call it like that, since in our case the label $x$ is used denote an angle and not a Cartesian coordinate). All vectors we work with are arrows attached to the origin $O$ of the coordinate system. So we are given a function $f(x) = a\cos(x) + b\sin(x)$. Then, define the two vectors $\overrightarrow{c} = a \, \overrightarrow{e}_1 + b \, \overrightarrow{e}_2$ and $\overrightarrow{v}(x) = \cos{(x)} \, \overrightarrow{e}_1 + \sin{(x)} \, \overrightarrow{e}_2$. These two vectors are like the two hands of a clock. The vector $\overrightarrow{v}(x)$ is a unit vector having angle $x$ with the horizontal coordinate axis determined by $\overrightarrow{e}_1$, and $\overrightarrow{v}(x)$ has length $|\overrightarrow{v}(x)| = \sqrt{\cos^2{x} + \sin^2{x}} = 1$. The other vector has length $|\overrightarrow{c}| = \sqrt{a^2+b^2}$. If you take the dot product between the two vectors you get $(\overrightarrow{c} \cdot \overrightarrow{v}(x)) = a\cos(x) + b\sin(x) = f(x)$ -- exactly the function you are given. Geometrically, this last dot product is the length of the orthogonal projection (the shadow) of vector $\overrightarrow{c}$ onto the line determined by the vector $\overrightarrow{v}(x)$. If $\theta$ is the angle between the two vectors $\overrightarrow{v}(x)$ and $\overrightarrow{c}$ and $A=|\overrightarrow{c}| = \sqrt{a^2+b^2}$ is the length of vector $\overrightarrow{c}$, then $$f(x) = a\cos(x) + b\sin(x) = (\overrightarrow{c}\cdot\overrightarrow{v}(x)) = |\overrightarrow{c}| |\overrightarrow{v}(x)| \cos{\theta} = |\overrightarrow{c}| \cos{\theta} = \sqrt{a^2+b^2} \cos{\theta} = A \cos{\theta}.$$ To calculate the angle $\theta$ between $\overrightarrow{v}(x)$ and $\overrightarrow{c}$, we can simply subtract from the angle $x$ between $\overrightarrow{v}(x)$ and the coordinate axis vector $\overrightarrow{e}_1$ the angle $\tilde{d}$ between $\overrightarrow{c}$ and the coordinate axis vector $\overrightarrow{e}_1$, that is $\theta = x - \tilde{d}$. Thus
$$f(x) = a\cos(x) + b\sin(x) = (\overrightarrow{c}\cdot\overrightarrow{v}(x)) = A \cos{\theta} = A \cos{(x - \tilde{d})}.$$ Almost there. We just rewrite the angle $\tilde{d} =\pi/2 - d$ and obtain
$$f(x) = a\cos(x) + b\sin(x) = A \cos{(x + d - \pi/2)} = A \sin{(x+d)}.$$