The strong nuclear force between nucleons is attractive but short range; the Coulomb force between protons is long range, but repulsive.
Unlike gravitational force, magnetic force can be attractive or repulsive in nature.