[AT&T, Rogers HTC One X, Telstra One XL] obsidian_eclipse:
It's caused by electrical noise. The voltage supplied from your mains outlet is alternating current (typically 50/60hz in frequency). a usb charger has to do two things; firstly step down the voltage (110v/230v/240v down to 5v) and secondly rectify the alternating current into direct current (positive and negative). how it does this is by using a transformer which employs an iron core surrounded by copper windings, this generates a lot of rf (radio) which travels down the cables to the device as well as broadcasting a short distance through the air, a decent charger will use shielding as well as a few other pieces of circuitry which will neutralize the rf given off. In order to rectify the voltage the charger will use a variety of diodes and capitors, in a cheap Chinese charger they will typically use as little as 2 and possibly a generic chemical capacitor (similar to a small battery) these degrade over time and can get quite hot, fat and eventually burst - when you hear about chargers exploding or setting on fire it's usually because the capitors aren't up to the job. a Chinese charger may have all the quality control and certification stamps but most of them are forged, if you buy a charger for less than $10 this is what your likely to end up with. the outputted voltage may appear 5v on a multimeter but they are a very dirty output and can spike from 3v to 7v or even more the load on the charger increases. The dirty output interferes with the mechanism used on touch screen devices which also employ a type of capacitance to register where you are pressing on the screen. A decent charger will use solid state capitors and which should last a lifetime.

if the smartphone miss behaves whilst charging 90% of the time it's because of a faulty charging device (or one employing poor components). a decent charger may cost more $20 but they are significantly safer for both you and the device.

The problem with mains sockets with built in usb usually comes down to shielding, they will either have none or be earthed (which might sound like a good idea but in practise a lot of domestic devices will create leakage to earth causing more noise - alot of studio equipment will have a separate earth). These may not be as dangerous as cheap Chinese chargers but still undesirable.

If a original or good quality charger isn't available one of the best sources for charging a phone will actually be a desktop pc with a usb3 port. The whole pc is insulated in a nice metal case and there are a plefora of high quality components to create a stable clean power supply (a cpu voltage tolerance is usually measured to 2 decimal places of a volt which is pretty good).

Ditch the rubbish cheap chargers, you honestly get what you pay for and they aren't good for the long term health of the phone. If it hums or makes a high pitch noise whilst plugged in your playing with fire - literally. they aren't bothered if your phone dies in 6 months or bursts into flames so long as they get the $5 x 100,000 people who buy them (these things literally cost pennies for them to put together, even though the case might look the business inside they are nasty and as cheap as)