Suppose we have some quantity $J$ which is defined for a particular (1D) bifurcation in the following way:
$J = \text{The number of stable equilibria - the number of unstable equilibria}$.
This quantity seems to be conserved in the sense that it is the same before and after the bifurcation. Eg for saddle nodes $J = 1 - 1 = 0$ before the bifurcation and $J = 0$ after.
This is also true for transcritical and pitchfork bifurcations (with different values of $J$).
What is going on here? Does this also hold in higher dimensions?
Yes, this is a topological invariant of the vector field, also known as winding number or homotopy class. The important fact is that this number is already fixed by the vector field far away from the equilibria, in the 1D case by the sign of the right side at the boundaries of some large interval. These signs do not change under small perturbations of the vector field, such as caused by the bifurcation parameter passing through its critical value.
In higher dimensions you also get limit cycles or stranger attractors that can "consume stability", so that a change in this index indicates the manifestation of such a positive dimensional limit object.
If one can exclude such, for instance for a gradient flow, then again the winding number over some boundary is the sum of the winding numbers of the equilibria inside the bounded set.