From the Super Mario Wiki
A Random Block is a special block found in Mario & Luigi: Superstar Saga. When struck, it will expel a coin and randomly turn red with an M, signaling Mario, or green with an L, signaling Luigi. The appropriate brother should hit the block for another coin. The block can switch colors, or it can stay the same, but the appropriate brother should keep hitting the Random Block for more coins. Eventually, the Random Block will turn into a Block.