How does a nine volt battery make a spark?

As the contact is being broken, a connection is made through very small pieces of metal (microscopic features), which have enough current through them to vaporize, the ions of which then support a current through the air briefly.

While lower voltages will not, in general, jump a gap that is present before the voltage is applied, interrupting an existing current flow often produces a low-voltage spark or arc. As the contacts are separated, a few small points of contact become the last to separate. The current becomes constricted to these small hot spots, causing them to become incandescent, so that they emit electrons (through thermionic emission). Even a small 9 V battery can spark noticeably by this mechanism in a darkened room. The ionized air and metal vapour (from the contacts) form plasma, which temporarily bridges the widening gap.

Wikipedia: High voltage § Sparks in air