To get the (color) paint perfectly on all sides they put the candies in a bin, like a cement truck which tumbles them over and over to evenly distribute the paint. To get the "M" on the candies, they are placed in trays like you would a muffin (trays with lots of dimples in them) and then are stamped with the "M."
This is a "microsoft" job interview question and there was a story about it in Reader's Digest a year or so ago. There was also a question about why Man Hole Covers are round rather than square. If you want that answer you can PM me, not going to type it all out.