I've been hesitant to post a response to this thread, mainly because I don't have an M&P 40; or any other 40 caliber handgun. I do own a FS M&P 9 and FS M&P 45.
In my opinion, what I see is that you are flinching and anticipating the recoil of the pistol. Trust me, you're NOT the only shooter to do this!
I also see from this thread that folks with a conversion barrel for 9mm, shoot it better than the 40 caliber. Part of this, I feel, is psychological-you don't expect the recoil to be as bad/snappy from the 9mm; so there's less of a flinch when you fire.
I just had the opportunity a few weeks ago to shoot a Beretta PX4 in 40 caliber. In this compact gun, I was expecting some pretty snappy recoil; I was surprised when it didn't feel much different than my 9mm. Not sure there was any more recoil than from my M&P 45, as I think the 45 is a pretty soft recoiling gun (to me).
I would suggest shooting your gun from a stable rest, concentrating on your sights/sight alignment and your trigger squeeze. If you control as much of the gun movement (downward from anticipating the recoil) I think you'll see the gun print closer to center of target. Once you see the gun will shoot to P.O.A. then you can concentrate on controlling your flinch when shooting off hand. Knowing what you need to work on will enable you to overcome them, and you will see positive improvements with each range trip. I am by no means an expert, but I know what I've had to do to overcome some of the same issues. I shoot 2" - 3" groups out to 15 yards with both M&P's and my SD9VE. When I have a "flyer" or rounds from the main group; it's NOT the gun and I know this.
I hope this helps, it's frustrating when you don't hit what you're shooting at. I know from experience!