From the Super Mario Wiki
Ads keep the MarioWiki independent and free :)
Counterattacks are a type of attack present in the Mario & Luigi series. When enemies attack on their turn, it can be countered by the playable characters, dealing extra damage to them. Almost every enemy provides a hint of which character it is going to attack (and thus which one needs to perform the counter). The counterattack's power is the same as a failed attack on the player's turn.
Mario, Luigi, Baby Mario, Baby Luigi and Paper Mario counterattack enemies using their hammers and jumping ability; in Mario & Luigi: Bowser's Inside Story and Mario & Luigi: Bowser's Inside Story + Bowser Jr.'s Journey, Bowser's counterattack moves are punching and ducking in his shell. If the player has a character's attack power increased, it will also boost their counterattack's power, though if the characters are under the effects of a Boo Biscuit, counterattacks deal no damage.
Counterattacks also appear in the giant battles of Mario & Luigi: Bowser's Inside Story and Mario & Luigi: Dream Team. Super Bowser or Giant Luigi use the touch screen to use their respective abilities to counterattack.
In Mario & Luigi: Paper Jam, Mario & Luigi: Superstar Saga + Bowser's Minions and Mario & Luigi: Bowser's Inside Story + Bowser Jr.'s Journey, the Emergency Block / Guard was incorporated making it a lesser, but easier, alternative to counterattacks.
In some games, the player can only win certain battles by only counterattacking; those battles being the battle with Shrowser in Mario & Luigi: Partners in Time, Thunder Sass's battle in Mario & Luigi: Dream Team, and Ludwig's battle in Mario & Luigi: Superstar Saga + Bowser's Minions. In Mario & Luigi: Paper Jam, a group of Hammer Bros. take away Mario, Luigi and Paper Mario's Command Blocks once they capture and imprison them in Twinsy Tropics Dungeon. Before they acquire any blocks that allow them to directly attack, the trio must defeat the first few Hammer Bros. using counterattacks.