How do circuits work where from the touch of a button on the wire of a headphone, you can pause or play music?
There is no general answer here, so the answer is: it depends.

Some headsets have an extra wire to the phone and pressing a button shorts that wire to ground via a resistor. If you want 2 buttons, use 2 different value resistors, a circuit in the phone detects which resistor is connected so then it can deduce which button you pressed.

On a wireless headphone or headset there could be a wireless connection to the phone, for example bluetooth. So there the switches are connected to the bluetooth chip in the headphones.

A simple remote via cable could be made by just shorting the audio signal line to ground. That will give a "click" in the sound though. Again some circuit in the phone is needed to detect that the signal line is grounded because you pressed the button.