One of the basic equations governing the behavior of gases is the ideal gas law, where $P$ refers to pressure, $V$ refers to volume, $n$ refers to number of molecules, $R$ refers to the Boltzmann constant, and $T$ refers to the temperature in degrees Kelvin:
$$PV=nRT$$
The ideal gas law states that if you double the pressure of a gas, then the temperature in Kelvin will double. If you halve the pressure of the gas, then the temperature will halve as well.
So they shove a bunch of gas into a canister and put a "gas duster" label on it, now what? Well the gas will be hot, and over time it'll settle back down to room temperature as its temperature equalizes with that of the room. But here comes the interesting bit: when you let the gas back out, it'll be even colder than it was when you put it in, because you let the temperature equalize after pressurizing it. If you had pressurized it, causing it to heat up, and immediately released the pressure, the temperature would be the same. But because you let the heat escape after pressurization, the gas will come out at several degrees colder than room temperature.
In fact, because the number of particles, the volume of gas, and Boltzmann's constant can be assumed not to change, we can pretend that $n$, $V$, and $R$ aren't in there at all, and just say that pressure is proportional to temperature, which mathematically is generally expressed like this:
$$P \propto T$$
Now we can actually figure out at what temperature the gas will be when it leaves the can! According to the Wikipedia page for gas dusters (gotta love Wikipedia), maximum pressure for a gas duster can is around $10\ \textrm{bar}$. Typical pressure at sea level is just around $1\ \textrm{bar}$, so the gas temperature will rise to about 10 times room temperature (or whatever temperature the gas is shoved in the can at) when pressurized. This exact temperature doesn't really matter, because all the excess heat will escape when the can cools down to room temperature, before you let the gas back out. When it comes rushing out of the can, pressure will decrease by 10x, so temperature will decrease to $1/10$ room temperature in Kelvin, or about $29\textrm{K}$, which is about $-244\textrm{C}$!
Practically speaking, there are a few other effects involved, like phase changes, that reduce the actual change in temperature of the gas coming out significantly, so the actual temperature comes out to somewhere around $-50\textrm{C}$. But in short, that's why gas comes out cold from a gas duster!