This seems like a bit of sleight of hand. The tricky part is the use of the formula:
1 + 2x + 3x^2 + ... + n x ^(n-1) + ... = 1/(1-x)^2
This is perfectly legitimate provided -1 < x < 1.
Then the formula was applied to x = -1 to get:
1 -2 +3 -4 +5 – ..... to get 1/1 – (-1))^2 = ¼
This is a divergent series for x = -1 and strictly speaking, there is nothing you can say about it.
For example, (1 -2) + (3 -4) + (5–6) + .... = -1 + -1 + -1 + ... = – infinity
On the other hand:
1 + (-2 + 3) + (-4 +5) + ... = 1 + 1 + 1 +... = + infinity
The math in @PhiNotPi ‘s link is beyond my understanding, but apparently what mathematicians have done is to extend the formulas for convergent series to divergent series and somehow make sense of it.