so 9mm is better than 40? that's why 40 Glocks are flooding the street? Police trading in their glock 40 for glock 9s?
Without delving into an endless debate on ballistics, wound data, hyperion warp technology, black magic, reloading data 1900 thru 2010, thrown bones or any of the various other methods in which people defend which caliber is "best" the short and simple answer to your question is really just "no". Judging which caliber is best based on what the cops or the military buy is like judging which brand of mustard is best by tracking what Burger King uses. It just isn't as simple as saying this one is superior to that one.
For example, Police and Sheriff departments buy their guns in lots, and often times what they choose is influenced heavily by what they have to pay, hence the occasional reference in this thread to the .45GAP which is a pretty unsuccessful commercial cartridge by any measure. Glock, having invested a ton of money in developing that cartridge, offers pretty hefty discounts to police departments to buy those guns. Since the .45GAP is not, in and of itself, a bad round, some departments opted to select it because they could save considerable money by doing so. Larger departments, who obviously order larger lots of firearms when doing mass purchases, often have the ability to be more selective in their caliber choice because they are getting volume discounts. Keep in mind that plenty of departments are perfectly content with the good ol' .45ACP round and aren't going to change that come hell or high water. Militarily, the 9mm is the standard NATO handgun round. Since we are a member of NATO, we shoot what everyone else shoots, and that's about the long and short of that.
In the end, what you have is a slew of cartridges that all do similar things in similar ways, and while ballistics data tells one tale, it isn't the end all be all of caliber selection. The most common "fighting" calibers of today's world are the 9mm, the .40S&W and the .45ACP. There are others that are on the fringe, such as the .45GAP, the .357SIG and even the 10mm. Commercial viability aside, none of these cartridges is inherently good or bad, best or worst. 10mm fans are notorious for their zealous defense of that caliber, while the majority of people dislike it on account of it's purported recoil (which, incidentally, was the whole reason the .40 was developed anyway). Is it better or worse than a 9mm? In some ways yes, because it is simply a more powerful cartridge. On the other hand, it's harder to find ammo for, it does have a stronger recoil, and not everyone makes a pistol for it (though Glock does!). Because of those reasons, it is not an incorrect statement to say that it is not the ideal cartridge. On the other hand, the 9mm, while being the least powerful of all the major fighting calibers, is many people choice (to include mine) because it is soft shooting and it has a wide selection of bullet and load choices. With proper bullet selection, the 9mm is a perfectly good defensive round, with poor bullet selection not so much.
As far as the number of .40's available in your area, it's probably a Police trade in. They got new guns, and rather than just destroy the old ones, they are sold to the public at a discount over new models. Since departments are often standardized, you will of course see a pretty large number of one particular model on the market. If your department happened to have carried Glock 19's, that would be what you see on the market in droves. It doesn't mean a thing, good or bad, what caliber it is. Police trade-ins are just that and the sudden appearance of a particular caliber (or the adoption of a new one) has absolutely zero bearing on whether or not that caliber is better or worse than some other caliber.