Start by collecting 8 Power Stars as Yoshi. Then head to the mini-game room and enter the door marked with the number 8. Inside, you'll find a painting of Mario, jump into it to enter a world full of Goombas.
There's a secret star here too. To earn it, collect 8 red coins first. Progressing further also involves unlocking Luigi and Wario. To reach Mario, climb the vine while dodging Lakitu, cross the bridge guarded by Goombas, then jump into the hole to face Goomboss. Defeat him by swallowing Goombas and spitting them at him; do this three times, as in most Mario games, and a key with a red hat appears.
Grab the key, head to the room with the doors and the slide, and enter Mario's room. There you go, Mario is unlocked!
A couple of asides: some people mistakenly think Waluigi is playable, which isn't the case. Also, when you start the game and press Start to reach file select, look at the left side of the castle and you'll spot a 2D black box. Nobody's quite sure whether it's a leftover glitch or something Nintendo forgot to remove, and you can't break it with a cannon. Either way, hope this helps!