This is an equation for an expected value, which is just the average result you'd expect if you could repeat a probabilistic experiment many times. For example, if I made a 1 dollar bet with a 999/1000 chance I would lose and therefore lose a dollar, and a 1/1000 chance I would win and receive 2000 dollars (for a net gain of 2000-1=1999 dollars), then if I were to repeat this bet a very large number of times the average amount of money gained each time would be (1/1000)(2000 - 1) + (999/1000)(0 - 1) = 1.999 - 0.999 = 1, so it's a good bet to make in the sense that the expected value is positive. The general format of this sort of calculation is a sum in which each term is the probability of a possible outcome times the numerical value of that outcome.
The equation is doing something similar for a case where there is some act that causes some small good to the person who takes it, but if some sufficient number n people take it, it triggers some large form of collective bad. It seems that instead of treating the triggering of the bad as itself a probabilistic matter, my interpretation is that in the equation he's assuming that n people actually do take the action and so the bad definitely results, but he wants each individual to calculate the expected value for the utility of their own act specifically (not the expected value for the total utility created by all n people taking the act), given that there is a 1/n probability it was their action specifically that triggered the bad and an [n-1]/n probability that it wasn't. If the total good created by all people doing the act is g, then each person's individual act contributes a utility g/n (given his assumption 'we suppose for simplicity that each individual act does the same amount of good'). If the person's individual act is the one that triggers the bad, represented by a B (which I assume is supposed to stand for a negative utility though he doesn't give it a negative sign), then their contribution to the total utility will be (B + g/n). If the person's individual act is not the one that triggers it, then their contribution will be (0 + g/n)...of course it's unnecessary to actually write 0 in this equation but he presumably just does it to make the parallel with (B + g/n) more clear, since in one case a bad is triggered while in the other case no bad is triggered. Given these two cases, doing a weighted sum where the utility generated by each outcome is multiplied by its probability gives the expected value of utility (1/n)(B + g/n) + ([n-1]/n)(0 + g/n). After that it's just a matter of algebra to show this reduces to g/n + B/n:
(1/n)(B + g/n) + ([n-1]/n)(0 + g/n) = B/n + (1/n)(g/n + g[n-1]/n) = B/n + (1/n)(gn/n) = B/n + (1/n)g
The algebra you write in your question would only be correct if we assumed (1/n)(B + g/n) + ([n-1]/n)(0 + g/n) = 0, but that isn't being assumed and would actually contradict the assumption in the paper that B/n is more negative than g/n is positive ('But in the kind of cases that concern us, the total (extra) overall results are negative. That is, B is greater than g, and so B/n is greater than g/n').
Section 26 of Parfit's Reasons and Persons does consider the same basic question of an act that "may be wrong because it is one of a set of acts that together harm other people" even if it is individually harmless, but he does not write this particular equation.