How do volume control headphones work?
The Android spec. gives details

This article shows some good ways to make a volume control.  Basically it is just some buttons switching in different resistors between a couple of pins of the 1/8" TRRS headphone connector.  Normally these buttons would put the resistor across (in parallel with) the microphone.

A standard microphone needs two wires:  The mic output signal and GND.  But the mic also needs power, and this is provided on the same wire as the mic output signal.  Inside the phone there will be a resistor between the mic signal and power.  Our remote volume control will switch in a resistor between the mic signal and GND.  These two resistors will form a simple resistive voltage divider, where the resulting voltage depends on which button is being pressed.

Inside the phone this mic signal goes into a simple analog-to-digital converter (ADC) that will measure the voltage and figure out from there what button is being pressed.

Doing it this way is a little tricky and creates some compromises.  First thing is that you can't use the mic and the buttons at the same time.  Most of the time this is not a problem, but occasionally you'll want to mess with stuff.  The phone has to mute the mic whenever a button is pressed.  Otherwise there will be a loud pop in the audio.  Even if this wasn't an electrical problem, most remote volume controls also house the microphone and you would get a lot of mechanical handling noise in the mic just from moving your fingers around.