From the Super Mario Wiki
In The Super Mario Bros. Super Show! episode "Stars in Their Eyes", Mario, while fleeing from Space Troopas in a swarm of fiery meteors, accidentally damages his ship when it is struck by a meteor; due to this damage, the ship lost all it's fuel and had it's door knocked off, resulting in all it's supplies being sucked into space.
With the spaceship damaged, Mario was forced to crash land it unto the planet Quirk, right on top of Astro Mouser. Unfortunately, this crash damaged the ship even more, meaning, along with getting fuel and supplies, Mario, Luigi, Toad and Princess Toadstool would need to fix the ship as well.
After a lot of trouble with Astro Mouser, Moon Man Koopa and several Koopa Troopas, Mario, Luigi, Toad and Princess Toadstool managed to gain all of what they needed for their ship from the helpful Quirks. Repairing his ship, Mario left Quirk and battled Moon Man Koopa and his spaceship. After a perilous and narrow battle, Mario, Luigi, Toad and Princess Toadstool manage to defeat Moon Man Koopa and release the enslaved Quirks from his rule.
Along with supplieing it's crew with oxygen and regulated gravity, the spaceship also has a somewhat odd offensive capabilities; the ship could shoot blasts of spaghetti and meatballs from cannons mounted on the side of it.