M&P9s are hit and miss. I'm pretty sure only the M&P9 Full size models are affected, but yeah- some of them don't group at all. Most will group much better with either light or heavy bullets- mine likes 124gr+ better than lighter bullets but still is one of the least accurate pistols I've ever owned. You can google it, but S&W jacked up the timing on the unlocking of the barrel. Last I checked into it it affected about 1 in 4, but generally the M&P9fs is very inaccurate.
You can get an aftermarket barrel and it will fix anything. Have fun spending $200 to get your $500 pistol to shoot as well as it should from the factory.