From the Super Mario Wiki
Pirate Guys are adventurous types of Shy Guys that "sail the seven seas." However, in actuality, they only sail the seas surrounding Yoshi's Island. They are closely tied with Limbo Guys. Their first appearance was in Yoshi's Story, and they only appear in Stage 5-4: Shy Guy's Ship.
Pirate Guys also appear in Mario Kart: Super Circuit and Mario Kart Wii in the Shy Guy Beach course. They also appear in Mario Party, and Mario Party 8 as the flag-raiser for the mini-games Shy Guy Says and Flagging Rights. They also appeared in Mario Party 2 on the Pirate Land board where they would fire their cannons at the player sending the player flying through the air and back to start if they landed on the Happening Spaces on the bridge. Pirate Guys also appear in Mario Hoops 3-on-3 in the Koopa Beach court.
Pirate Guys reappear in Yoshi's Island DS, along with Pirate Guys who stack themselves on top of each other. They are like normal Shy Guys, except they wear bandanas and appear in beach-themed stages.