I was mildly surprised to learn that mosquitoes are attracted to some people more than others. People with high concentrations of cholesterol and steroids on their skin are more likely to get bit (Don't worry; this doesn't mean that you have high cholesterol. It usually just means your body processes it at a faster rate than average). An increased amount of uric acid, lactic acid or a number of other acids on the skin also makes a person more desirable. Finally, those who exhale more carbon dioxide than average, tend to attract more mosquitoes.
So, the first line of defense is to stop vigorous activity when you are in an area with mosquitoes. You'll breathe heavier and have more acids on your skin from sweating.
Now, let's say you enjoy participating in sports when it's 100 degrees out and you are invited to do so in a place where mosquitoes are flying around. Then what can you do? Break out the bug spray! The most common, is DEET. It comes in a variety of concentrations and the higher the concentration the longer you'll be protected. DEET has a bit of a bad reputation; claims have been made it has caused seizures and even some deaths. There is always a possibility of an allergic reaction but otherwise, proper use of the product has shown to be safe in even young children. By proper use I mean, don't spray in your eyes, mouth or ears. Only spray on clothes and exposed skin, use only as needed and take a shower once back inside (for further information, check the product's label).
As effective as DEET, Picaridin is another option. It's preferred by most, because it doesn't have a strong odor and doesn't have the same sticky feel that DEET does.
Metofluthrin is not applied to the skin. Instead is is used in emanators (devices like the OFF! Clip-On). This is a less messy option that has been shown to be effective.
Chemical IR3535, or better known to the public as Avon Skin-So-Soft is not as effective as DEET but does provide short lived protection (usually less than an hour).
Another more dangerous option is Permethrin. It's a neurotoxin so it's ONLY for use on clothing.
Now let's say you hate the idea of drowning yourself in chemicals every time you want to go out and enjoy a summer's day. There are some alternatives. There are soybean, oil-based products and a variety of other natural oils such as citronella, cedar and peppermint that can protect you. Of the oils, lemon of eucalyptus has been shown to be most effective.
Some studies have shown that mosquitoes don't like the odor of thiamine (B1). A patch was developed to leave the scent of B1 on the skin but there's no solid evidence to show wearing these patches keep the pests at bay.
There are clothes that have repellents right in them and there are traps you can put out for the mosquitoes. Plus if you eliminate their breading grounds (places with stagnate water and high concentrations of wet plant life), they might just go over to your neighbor's yard.
Back to the main question... how do they work? Well, they make you smell and taste bad to the mosquitoes. Which is probably why humans think they have an offensive smell. Let's assume they have a bad taste since testing that is probably dangerous.
So why do we all hate mosquitoes so much? To start, if a lady mosquito chooses to use your blood to produce her eggs, she leaves behind an annoying itch (luckily it only lasts for a few days). Others are allergic to them and wind up with moderate to severe reactions; from large welts lasting for days to the need for a hospital visit. It's pretty well known that mosquitoes spread malaria as well as yellow fever, dengue fever and encephalitis.
But we at least only have the females to worry about, they need the blood for reproduction purposes. The males feed only on nectar.
Their saving grace is that they have a some what important role to play in their ecosystem. They are the food of choice to to a variety of fish and birds and if they were to suddenly go existent, it would take away a major food source of these animals.
If you are unlucky, there are products out there that will ease the itch until it's healed. I personally recommend After Bite, which is what I use and provides relief.
Keep safe out there!