Heya Pick, welcome aboard,
Thiokol's got some spot on advice and I'd try that first, as I hear about that particular scenario with a number of S&W M&P 9's in particular--probably too many doing that for them all to be coming out of the factory 'not quite right'. I doubt if it's a problem with the gun.
Different caliber guns move in different ways, even different brand guns of the same weight and caliber move differently. Developing/refining correct breathing, consistent habits/ergonomic movements and knowing your guns idiosyncrasies takes time. A cup of coffee or a couple coca colas effect my accuracy for sure--I typically shoot too high then.
But some guns are just 'that way' sometimes due to the way that particular barrel turned out and adjusting the sights can be an ongoing PITA of little help. In that case--you and the gun 'meet in the middle'.
Thiokol's advice can only help, but if not enough, you might consider aiming a bit high and to the right and just remembering to do that with that gun, if changing your technique doesn't work.
I know that with a bow and arrow, when I had an apple on my head, my exwife always adjusted her aim lower.....LOL