You just run to the left of the castle and throw your hat on a scarecrow. And stairs appear!
But I think the scarecrow doesn't pop up until you re-visit all the worlds and talk to Peach in each one.
I also couldn't figure out how to get the fruit out of the pipe in the castle moat...then it hit me that you just pull out the wooden pegs at the bottom and it drains.