A lot of it is due to luck or fads...
Other than things like custom guns, guns previously owned by famous people or low production runs, some things than can increase the value of your firearm are:
The movie industry helps sell and resell certain firearms. Dirty Harry's S&W .44 created a huge demand, thus higher value, handgun. Same with the Beretta from
Die Hard and
Lethal Weapon, and the Glock 17 from
Die Hard 2.
Black Hawk Down made everyone wanted a M4 clone.
Miami Vice helped cause the wonder-nine craze of the 80's.
Rumors of bans on certain catagories of guns also increases the desirability and value of the effected guns. The assault weapon ban caused the value of those guns to double or triple overnight, long before it was actually signed into law in 1994. All of the hype and proposed bans of the .50 BMG have made people want to get one now, just in case it gets banned.
High profile crimes also can effect the demand and value of a firearm. Following the North LA shootout, everyone wanted an AK-47 clone. The Secret Service agent holding the Uzi over John Hinkley in 1981 resulted in a surge in Uzi carbine sales. Those that did by an Uzi carbine also benefited from the AW ban raising the value even more.
My Uzi's increased ~$700 in value in the 10 months I've owned it.
My MP5SD and M16A1 are around 5-6 times what I paid for them.
Of course, it's been a little longer than 10 months.