For law enforcement purposes I personally believe the .40 would be preferred due to higher ballistics. It represents the best overall choice for stopping power, accuracy, and ease of use. Yes the 9mm is cheaper versus the .40 for a LEO agency, which a lot of departments will factor the costs in. A little history the 9mm was established in 1902 by George Luger and the .40cal was designed by Smith & Wesson in the early 1990's for the FBI that was replacing the 10mm cartridge.
The two choices of side arms you posted, I would prefer the Glock over the M&P due to it's reliability, function, and ease of break down. Also, I'm a Glock fan. I've shot the M&P's and don't like the fitment nor characteristics of the M&P. I could go into great detail but I'll stay away from that, as of now. Also Glocks are cheaper to service over the M&P's I've noticed. The factory trigger on the Glock's, I like the shorter reset of them versus the M&P's.
I know both are great guns and probably can't go wrong with either or. These are my thoughts of each of the fire arms. Shooting competitively for quite awhile, I love my modified Glock's and the 9mm round, because I can load the 9mm a lot lighter to control the recoil for better target transitions. Like I stated before these are my personal thoughts on both great side arms.