From the Super Mario Wiki
M Blocks are items found in the Mario & Luigi series and they serve as the same function as a ? Block. This type of block can only be activated by Mario and Baby Mario, whereas the similar L Block can only be used by Luigi and Baby Luigi. They may contain items for the Mario Bros. to collect.
M Blocks also appear in Yoshi's Island DS. In this game, Yoshi must be carrying Baby Mario to see them and hit them. Also, some remain invisible even with Baby Mario; these blocks must be hit by Yoshi (with Baby Mario) to appear. The stage Hit the M Blocks! is named after them.