Short answer: Your selfie stick is pretending to be a set of iPhone headphones and pressing the button on your stick is actually the same as pressing the volume up or down button which captures a photo. You can do the same with normal iPhone headphones, or by pressing the physical button on your iPhone.
Note: +(ve) and -(ve) refers to positive and negative respectively.
Depending on the model of iPhone you have, most modern iPhones since the iPhone 3GS have the ability to control the the volume of audio playback through the remote built in-line in compatible headphones.
The headphone jack on a typical music device would be either TS (mono) or TRS (stereo), meaning that it has a Tip section, Ring section and a Sleeve section.
Headphones are essentially speakers, and like most electrical devices they work on the idea of a circuit, from +(ve) to -(ve), so a stereo set of headphones is basically two speakers. One for each the left and right channels, so you need two wires, one for each, and a third that connects both back to the -(ve) side of the circuit. Thats why a stereo headphone jack is TRS (Tip, Ring, Sleeve).
The tip section of a headphone jack is always the left channel (or mono), the 1st ring section is the right channel, and the sleeve section is the -(ve) connection, this sleeve being -(ve) is important for later...
Even since the original iPhone there has always been a remote control inline with the right ear bud, and a microphone also. This allowed you to pickup calls hands-free and also play/pause, skip and rewind tracks by clicking the button.
To implement these extra features required a special type of headphone jack, a TRRS (Tip, Ring, Ring Sleeve) jack, it's no bigger than a normal jack and whats really clever is that the additional ring is in the section where the sleeve would be on a normal headphone.
The reason this is clever is that when you use your TRRS type headphones on a device which is a normal music player, the microphone bit just gets connected to -(ve) and is thus essentially disabled but the left and right channels are connected as normal so your smart iPhone headphones become normal headphones without any chance of the microphone or buttons becoming a problem.
Anyway, back to the original question, using some (to the non-layperson) basic electronics the extra Ring section can be used to send electrical pulses that send the volume up/down and play/pause buttons and microphone through this channel.
Since iOS 6, you have been able to use the volume up (and later down) button(s) on your iPhone, or headphones to capture a photo. This was in response to a number of third-party photo apps that popped up adding this feature with ever increasingly clever ways of hiding this from Apple's App Store reviewers.
So essentially the selfie stick is pretending to be a pair of Apple Headphones and pressing the volume up or down buttons. You can probably verify this by going into the Music app and pressing the capture button.