Honestly, all things considered, both are excellent choices and it really comes down to preference. I prefer the M&P because it fits my hand better, it recoils smoother, I find it more accurate, and it's just as easy to maintain as the Glock. While the Gen4 frames do fit my hand better than previous models, Glocks don't point as well for me and are just plain uncomfortable.
Glock is largely popular for two reasons: 1) Because they are cheap to make, they can give almost unmatchable deals to LE and military, 2) Glock has a major cult following. While every gun company and model has their extreme cheering section, Glock has the loudest, largest, and most "monotheistic" fanboys. I know a lot of S&W owners who also own a lot of different styles (including Glocks), but the Glockaphiles only like Glock. They always tell stories about how they used to have Sigs, HKs, S&Ws, 1911s of all shapes and sizes, and how NONE of them could even get through a whole magazine, but of the 50 Glocks they've owned, NONE of them have ever jammed and they haven't even had to clean them. I can't tell you how many times I've heard people say, "The ONLY gun I would trust my life to is a Glock." Well, if there is only one model of pistol in the entire firearms industry that is reliable, the firearms industry is in REALLY sorry shape! I will say, that H&K's extremists are nearly as annoying, but they are fewer (due to the higher prices of HK).
Now, if a person owns only Glock because he/she loves the way they fit, they shoot them well, and overall, they are satisfied, that's great. I just don't like the Glock fans who look down on absolutely every other gun in the industry and treat anyone who isn't as crazy about Glocks as though they have some kind of mental issue.