I've owned six M&P's (M1.0's & M2.0's) since circa 2005 and and six Glocks (Gens 3, 4, & 5) since 2012. The truth is, in my opinion, accuracy is
usually subjective and dependent on how a person biomechanically interfaces with the pistol, and even this is largely dependent on taking the time to warm up to the pistol. In fact, if you own both and haven't shot either one for a long time, you can find yourself having to get used to it again.
There are a few exceptions. Sometimes you can get a trigger or a barrel that might have a minor flaw that can sacrifice a bit of accuracy (the M1.0 had some barrels like this at one time as discussed by mrgunsngear, but they've always been supremely accurate (both M1.0 and M2.0).
Moreover, you can also dial in both Glocks and Smith & Wesson M&Ps to be more accurate if necessary by changing the grips and/or trigger. If you're still not happy with the results, SOME (certainly not all) aftermarket barrels can improve accuracy as well.
If you're worried about the accuracy of an M&P, for example, you can get an "Apex Grade" barrel which improves accuracy by improving the lockup (which I think they've patented). Remember, however, that Apex Tactical also makes non-Apex Grade barrels which do not claim to do this but have a threaded barrel. If you have a S&W with a barrel they don't make the Apex Grade for (e.g. 3.6"), then you can certainly get an excellent barrel from companies like Bar-Sto (but to get the greatest accuracy, you'll have to get it handfit by the company which can get expensive because of the shipping).
I have a Bar-Sto for a SIG P229, and it is excellent, however, I did not get it hand fitted, so while the vertical lock up is excellent, there is some lateral movement that may or may not sacrifice accuracy (for competition, but not practical accuracy such as for self-defense). I carry the gun in .357 SIG, so I only needed a decent barrel for practicing with 9mm (as .357 SIG is expensive). But even if I plan to carry it for self defense, only practical accuracy is necessary for self-defense, and tighter tolerances can also make a pistol less reliable (not usually, but sometimes).
I had to handfit the Bar-Sto barrel to get it to fit (which is expected and actually a good sign that the vertical lock up is nice and tight, but the more important thing I want you to understand is that practical accuracy is not a cop out. Like I said, looser tolerances can make a pistol more reliable especially when facing the elements (mud, dirt, water, sand, etc.), and on the flip side, the difference between match-grade accuracy and practical accuracy won't normally translate to better self-protection, and not only is this an age-old maxim in the gun world, but I know of at least one study that bares this out (
An Alternate Look at Handgun Stopping Power | Buckeye Firearms Association).
The Buckeye Firearms study comparing calibers looked at about 1,800 bodies shot in gunfights, and it tracks such metrics such as the inability to incapacitate a person, how many hits it takes on average, accuracy looking at head and chest shots and other data. The more accurate calibers typically did not provide and advantage, and in some cases, were technically less effective (though certainly within the margin of error in most cases). Some clearly had greater accuracy than others but did not stop people as well because of other factors such as over penetration or under penetration. Simply put, slightly tighter groups do not seem to translate into better stopping power, at least in terms of comparing calibers. Making consistent center of mass hits and headshots is good enough. Again, we're not talking about ballistic gel tests here, the study actually shows what happened with 1,800 bodies shot with various calibers in real gunfights and accuracy was absolutely not an indicator of effectiveness. No study is perfect, but the law of large numbers in statistics makes 1,800 a much better number than the number of rounds as individuals we are likely to shoot making comparisons.
Depending on your ability to warm up to either Glock or Smith & Wesson, you may not find upgrading anything on your pistol at all necessary either in terms of practical or match-grade accuracy in competition (which is often not permitted in certain competition anyway).
That all said, there have been times outside of Glock and Smith & Wesson where I just couldn't warm up to a pistol no matter how much time I had behind it. My two FN FNS pistols come to mind. For whatever reason, sometimes it's not possible to warm up to a pistol because the ergonomics are not a good match even when you change the backstrap or trigger (e.g. trigger reach). In fact, I was slightly less accurate with my Gen5 Glock even though it is supposed to have a better barrel because my trigger wasn't as good as my Gen4's. The difference was so minimal that it wouldn't show most of the time. But there is something about at least my sample of a Gen5 G26 that wasn't quite as good as my Gen4 G26, but we have to keep in mind that even samples of the same exact gun (generation and all) can be individuals and even prefer different ammunition. So when someone claims they received better accuracy with one or the other using the same ammunition, all they can really say is that they are capable of getting better results with one or the other using that ammunition, but they're not even coming close to proving it scientifically. They would have to shoot many rounds comparing ammunition to find what ammo a particular pistol favors. Then they can compare guns using their best loads to put many more down range to eliminate other variables (like waking up on the wrong side of the bed that day).
I'm not trying to talk people out of seeking the best accuracy possible, but I am trying to put it in its proper context because more times than not people waste a lot of money "upgrading" firearms and buying & selling them in pursuit of the greatest pistol on earth when in all actuality practice is going to have a far greater impact on practical accuracy than the pistol itself. Generally speaking, a reliable firearm is the most important thing when discussing these types of pistols for their normal use outside of competition. Most of the firearms built today are plenty accurate in terms of effectiveness in a self-defense situation. You just want to make sure it is going to work when you need it. Take it from someone who has spent thousands and thousands of dollars on dozens of concealed carry pistols over the last 16 years.
Last but not least, I did end up selling my last Glock almost two years ago. For concealed carry I've maintained two Smith & Wesson M2.0 M&P9's (3.6" Subcompact and a Performance Center Shield), a SIG P229 Enhanced Elite in .357 SIG/.40 S&W, and 9mm), a Langdonized Beretta PX4 Storm Compact in 9mm, and a Ruger LCP II in .380 ACP. The reason being that, in my hands, the way I biomechanically interface with a pistol, these firearms shoot (point) more intuitively for me than Glocks. Don't get me wrong, I shoot Glocks very accurately, but when you're switching between platforms (and grip angles) all the time, Glocks require you to cant your wrist more than others, so while I am strictly focused on Glocks, this isn't a problem, but when I am bouncing between many different firearms, I sometimes shoot a bit too high with a Glock. People who put more rounds down range than I do may overcome this switching between platforms, but for me, there are only so many rounds I can buy and only so many hours in the week I can dry practice, so I made the decision to go with a set of firearms that work best for my concealed carry needs. But I will say that, for me, even though my M&P's point more naturally than the Glocks I've owned in the past, it's not by much and my SIG P229, Beretta PX4 Storm, and Ruger LCP II are marginally better (point more naturally). Again, that's my hands and certainly not necessarily yours or anyone else's.
Anyway, good luck and I hope this long comment I just wrote at least gave you and some others some information that is useful.