Once you're in, jump straight in the cannon in front of you, then aim all the way to the left and just above the fence, then fire!
when you land, run straight ahead past the big rock until you get to a ring of coins. Run around in a circle, collecting all of the coins and a mushroom will appear. Collect it, then run down the hill just in front of you to see a bob-omb patrolling the entrance to a tunnel under a bridge.
Run past (or kill) the bob-omb, then collect the life mushroom in front of you. You should now have 2 extra lives.
You can now press start and exit the course and you will find yourself in the castle again. You can now go back into the battlefield again as many times as you like, collecting 2 lives each time. Perfect if you're coming up to a boss level!