From the Super Mario Wiki
A Random Block is a type of block found in Mario & Luigi: Superstar Saga. When hit, it will release a coin and either turn red and display an "M", signaling for Mario to hit it, or turn green and display an "L", signaling for Luigi to hit it. If the correct brother hits the block, another coin is released. It is random whether it changes between colors or stays the same color once hit. Eventually, the Random Block will turn into a Block.