From the Super Mario Wiki
Vegetables (also known as Veggies) are plants that are found in the Real World, yet can be planted in Mushroom Kingdom and Subcon. They can be pulled out of the ground and can be thrown at enemies to damage or defeat them. They are first introduced in Yume Kojo: Doki Doki Panic (a Turnip only) and the Mario game, Super Mario Bros. 2.
Super Mario series
Super Mario Bros. 2
Vegetables are first found in Subcon in the game Super Mario Bros. 2. They can be plucked with the B button and thrown at enemies. There are two kinds, unripe and ripe. The ripe ones are much larger than the unripe but they're still just as effective when throwing. Almost all the red grass in the game is a vegetable when plucked. Some of the ideas for what kinds of vegetables they are is turnips, onions, beets, radishes, and other root vegetables.
These are the only effective weapon against the evil Wart in the last level. The pale vegetable in the bottom right side of the picture to the left is only seen when thrown out of Wart's Nightmare Machine.
BS Super Mario USA
Vegetables returned in the game BS Super Mario USA. They are used in the same manner in the predecessor. The game introduces giant vegetables that can't be picked up. Instead, these giant plants only appear as spells cast by a character who appears on the screen as a card.
Super Mario Advance
Vegetables return in Super Mario Advance, working the same way they did originally. This version of the game, however features pickable giant vegetables, which take longer to pull out. They work the same as their normal-sized counterparts, but can hit more enemies, due to their bigger size.
Super Mario Advance 4: Super Mario Bros. 3
Using e-Cards, vegetables can be brought into Super Mario Advance 4: Super Mario Bros. 3 thanks to the Blue Green Switch. They can be used in the same manner. The game also features pickable giant vegetables, from Super Mario Advance.
The Super Mario Bros. Super Show!
Vegetables appeared in some episodes of The Super Mario Bros. Super Show!. Mario and Luigi use them in various episodes to defeat their enemies, the Koopa Pack and King Koopa like in Super Mario Bros. 2. The vegetable-throwing sound from Super Mario Bros. 2 is also commonly used in the show even for things such as the firing of a Bullet Bill and the throwing of a fireball.
Mario vs. Wario
Vegetables were given a minor appearance in one of the Mario vs. Wario comics. The first page of this comic showed Mario recalling "playing in the garden" with Wario when the two were friends; during this scene, several vegetables are present and Wario even picks one up Super Mario Bros. 2-style. Wario, too, remembers this garden scene on the next page, although his memory is a bit less fair: He recalls Mario asking for help in the garden and taking a row of turnips as his own, leaving Wario to tackle the Piranha Plants on his own.
In Super Smash Bros. Melee, Princess Peach can also throw these items as her down & B attack, which itself is called "Vegetable". Almost every one she plucks has a different expression, which pertains to the amount of damage it will inflict. The damage of the Vegetables range from 7% damage to around 35%. Peach can also pluck up Beam Swords, Mr. Saturns, and even Bob-ombs. There is also a Vegetable trophy.
Peach's Vegetable move re-appeared in Super Smash Bros. Brawl, working the same way.
Another type of vegetables are food items that are only found in the Brawl stage Summit. When they are eaten, they make a special, different sound effect from the other foods.
Mario & Luigi: Bowser's Inside Story
In the boss battle with Wiggler in Mario & Luigi: Bowser's Inside Story, the Wiggler may water the ground and some sprouts will grow. Two of the three possible things he pulls out are ripe and unripe turnips.
Captain Toad: Treasure Tracker
Turnips make a reappearance in Captain Toad: Treasure Tracker, after being absent for 5 years, Captain Toad can now throw these at enemies to defeat them, Captain Toad will use large turnips in Wingo's boss fight to defeat him.
Names in other languages