Take a look at the infinite grid below. The main diagonal is filled with 0s, and each column has an infinite geometric series of positive numbers below the 0, while each row has an infinite geometric series of negative numbers after the 0.
If we sum every column we get 1, then 1/2 (since the first term of 1/2 cancels out with its negative counterpart from above the 0) then 1/4 and so on. Summing these results we get that the total sum of the whole infinite grid is 2.
However, if we perform the same technique to the rows instead we get the result of -2. Let's go even further and try summing the diagonals:
This time all the positive terms cancel out with their negative counterparts which gives a total sum of 0.
Let’s try another similar example that Terry Tao (who has the rare trait of being a mathematician mentioned on this website who is actually still alive) uses to illustrate this same problem:
This is essentially the same structure but with all of the unnecessary complication stripped away. Again the sum of the rows and columns give differing results. You can actually rearrange the grid to get whatever result you like. For instance if you swap the places of each -1 with the 0 below it and then sum the rows then you get a result of 1+1+0+0+0+0+0+...=2. By swapping the -1s with 0s even further down we can get any positive integer. By symmetry we can also get any negative integer.
If you have a sum of a finite series like s=1+1/2+1/4 we can uniquely define what the result is. However when a series goes infinite we can only assign it a sum if it is absolutely convergent. Any sum which has both an infinite number of positive terms and an infinite number of negative terms can still be convergent, but not absolutely convergent, so we can't get a sensible value from it. As a general rule of thumb, if you are rearranging the terms of an infinite series in order to take the sum then you are breaking the rules. If you have seen then 1+2+3+4+...= -1/12 result then you have seen exactly this at work.
Just as a final minimal example of hijinks take 1-1+1-1+1-1… it can either be grouped as 1-(1-1)-(1-1)-(1-1)...=1-0-0-0...=1 or as (1-1)+(1-1)+(1-1)...=0+0+0…=0.