From the Super Mario Wiki
Watermelons are fruit that appear in several games of the Mario series and differ from game to game. They're based on the real-life fruits and strongly vary in size. Watermelons appear mainly in Yoshi series, along with many other kinds of fruits.
In Super Mario World 2: Yoshi's Island and Yoshi's Island: Super Mario Advance 3, there are three different types that offer special attacks. Super Green Watermelons allow a Yoshi to spit out the seeds as projectiles; if it already has a bite mark in it, there will only be a third as many seeds. Super Red Watermelons allow three shots of fire breath that burn enemies and melt Ice Blocks. Special Blue Watermelons allow three shots of ice breath that freeze enemies, making them harmless and immobile and causing them to break apart when a Yoshi touches them.
In Yoshi Touch & Go, Watermelons, when eaten, give Yoshi five eggs.
Super Mario series
Super Mario Sunshine
In Super Mario Sunshine, massive Watermelons appear. In Gelato Beach, the Surf Cabana makes Watermelon smoothies, and there is a Watermelon Festival to show off the person with the largest Watermelon. The Watermelons there are quite sensitive to pressure, and act and look more like water balloons. In the secret levels & Pianta Village, Watermelon Blocks can be found, which act as breakable Blocks.
Super Mario Galaxy / Super Mario Galaxy 2
In Super Mario Galaxy and its sequel, when 9999 Star Bits are collected, all the green coconuts in the game turn into Watermelons. In Super Mario Galaxy, a Watermelon is featured in the "Bubble Blastoff" mission in the Deep Dark Galaxy. Mario lands on a glass planet where he must Ground Pound the three encircling tennis balls within the planet which will hit the Watermelon in the center and cause it to grow visibly larger until it shatters the glass planet and becomes the new planet.
Donkey Kong series
Mario Party 5
In Mario Party 5, green Watermelons similar to those found in Super Mario World 2: Yoshi's Island appear as a battle weapon worth seven battle points.
Mario Hoops 3-on-3
In Mario Hoops 3-on-3, the Watermelon is one of the unlockable basketballs.
Mario Sports Mix
Watermelons also make an appearance in the Wii game, Mario Sports Mix. In this game, they are objects that appear in the minigame, Feed Petey. If the player shoots one watermelon into Petey Piranha's mouth, they are awarded fifty points. To obtain the watermelon, the player must jump up under the watermelon. The watermelon is suspended in midair on a rope.
Luigi's Mansion: Dark Moon
Watermelons make a few appearances in the microgames of the WarioWare series. In WarioWare, Inc.: Mega Microgame$, Body Block involves people keeping a watermelon bouncing around. In WarioWare: Touched!, these fruit appear in Steel Chef, It Slices, It Dices, and Global Warning. The microgame Universal Marionette from WarioWare: Smooth Moves features watermelons as well.
Watermelons appear in volume 14 of the Super Mario-Kun, which is the adaption of Super Mario World 2: Yoshi's Island. Here, as in the game, they give characters who eat it respective abilities. The first time they appear, Mario and Luigi stuff a Super Red Watermelon inside a crying Baby Mario to quiet him. He then breathes fire at Toadies who first attempted to attack. The next time they appear, Helicopter Yoshi eats a Super Green Watermelon and spits seeds at Kamek, Toadies, and Baby Mario they are carrying. During their battle against a Lunge Fish, Mario stuffs a Super Blue Watermelon inside Yoshi to make Yoshi freeze the Lunge Fish.