A lot of people don't know crap about firearms, and this includes police and military types, who should. Those who do, have opinions about the weapons, but know that they work and that is what counts.
I'm not out to bad mouth rappers or gang members, so this isn't about that. Most gang members use simple and effective weapons, and the cheaper the better (since they are illegal in most cases and prone to "disappear" under various reasons). Thus, they favor guns like the AK-47, which you can get almost anywhere, has a good reputation for working, and has a very effective image, thanks to the media. Like you said, a legal version runs about $500 in the US, and illegal ones are even cheaper. I've seen AKs sell, fully automatic versions, for less than $300, and sometimes half that, where they are really common. The AK-74 is a little higher, or cheaper, depending on the image it has, and how ammo is. In the last ten years, they may have come down, but were fairly rare since they were still "hot" weapons before the break up. And, in most cases, the AK can be made Full auto with a little work, and this makes it even more attractive to some.
The AR -15 is about twice the price, harder to modify, and tends to project a police image, which makes it less attractive. Even if you have the cash, as most drug dealers do, why pay to give it to the cops when they make an arrest, and take the weapon? Drug dealers are not stupid, even if people think they are. The M16 can be much cheaper, is full auto, but still carries a lot of time and a "bad" image. It also has the "rep" for being a problem weapon, which came from the very first M16s that where shipped to Vietnam, back in 1966. A change in powder and lack of cleaning caused the problems, but it was bad enough to cause a dislike of the weapon even today. They usually do a lot better, especially the AR semi autos, but I hear the M4 is different, due to changes in the way it is done today. I have owned and fired a lot of ARs with very few problems, and only 1 M16 has messed up, very badly, but that was an issue that could have been prevented, I'm told, and was made worse by my firing it "left handed" instead of how it was made to be fired (right handed, which would not have cause an injury).
I recall Ice-T singing about banning the AK, which he had stashed with a "case of hand grenades" in one of his songs. Such themes, being realistic and popular, have helped the image along, as have the repeated use of violence by murders, in schools and work-places (such as Post Offices), where the media focus is on the weapon, as if it made the person do those things, not being a tool of a vengeful and unbalanced person who the system FAILED to catch or caught and let go because they were too busy with stupid things like persecuting those they dislike (Blacks and others).
For a poor person, $500 IS expensive. But, the Soviets built the AK cheaply, and worked to make it cheaper so they could produce millions of them. They are simple, well built weapons. Today, however, most people seem to be able to afford $500 for a weapon, even if they cannot afford baby food (another government issue) or need a home, and the social system doesn't care unless they can get something in "return" for their help.
I like the AK series for simplicity in manufacture. However, they are too short for me to really like to shoot. The newer M16 A2 addressed this, being a little longer, and was much more simple to work on, having only few parts to the fire control system. I haven't seen or fired the A3 and up, so I can't really comment. The AK-74 was more effective, lethally, than the A1, but the A2 + have addressed this and seem to be a little better. However, the .30 caliber AK-47 still have the best reputation for stopping, due to the larger wound it creates. I will pick an M16 in most cases, but feel fine with the AK too. But, at close range, give me a shotgun or a 7.62x51mm for longer ranges. In any event, anything is better than having nothing but a knife or your fists when the other guy(s) have a gun.