How do media buttons on a plain wired headset work?
Each switch bridges the high-impedance microphone with a low resistance, allowing internal circuitry to sense the buttons. Here's a helpful image:



The MIC+ line has a bias voltage (to supply the mic), and by adding some additional circuitry to the mic preamp, it's easy to differentiate those resistor values.

This is the most common scheme for "on-headphone" controls. Additionally, it's very easy to implement in the headphones, allowing for cheap headphones and requires only a little bit more circuitry in the phone.