While I would never give any kind of chocolate to a dog, the truth is that the milk chocolate in m&ms would probably not be harmful. If your dog gets into seriously dark chocolate, see a vet asap, but if you know it’s just milk chocolate, you shouldn’t worry.
Also if it’s sugar-free with Xylitol. It’s poison for dogs.