Under what condition the magnitude of sum of the two vectors is equal to the sum of their magnitudes?

In $\mathbb{R}^n$, we have that your equality implies $$\langle a+b,a+b \rangle=(\Vert a\Vert+\Vert b \Vert)^2 ,$$ which, using the bilinearity of the inner product, yields $$\Vert a \Vert^2+\Vert b \Vert^2 +2\langle a,b \rangle=\Vert a\Vert^2+\Vert b \Vert ^2 +2\Vert a \Vert \Vert b \Vert$$ $$\implies \langle a,b \rangle= \Vert a \Vert \Vert b \Vert.$$ And equality on Cauchy-Schwarz only holds if both vectors are linearly dependent. (Note that since there is no modulus on the inner product on the left side, not only they must be linearly dependent, but also differ by a positive scaling).

As a sidenote, the technique above holds for any inner product space. One might be tempted to extend it to any normed space, but the result isn't true. As an example, one can take $L^1([0,1])$ and $a=I_{[0,1/2]}$, $b=I_{[1/2,1]}$, where $I_A$ is the indicator function on $A$.