Decongestants work by reducing blood flow to your mucus membranes. This lessens the amount of water that can get to the membranes, and so cuts down the amount of water that can get out of the membranes. Often this cuts down on the volume of mucus. Sometimes it just makes the mucus thicker and harder to cough or sneeze out. Decongestants also do nothing for the root cause of the excess mucus, so if the decongestant wears off before the irritant or virus does, you're back where you started.
Most decongestants are chemical relatives of adrenaline.
Some are meant to be taken orally, while a few are made to be sprayed in the nose. I personally recommend to my patients that they never use nasal spray decongestants for that reason. Since decongestants are related to adrenaline, they can make some people jittery. Small children seem to be especially susceptible to this. I never recommend decongestants in children under 6 months old.