Under the Castle Grounds

Description
This is a useful glitch in Super Mario 64 DS. ...Well, kind of useful. Go outside the castle as Mario or Luigi. Run over to the cannon. This glitch works better if you have not yet drained the moat. Face the hill next to the cannon. It is the one with all the trees on it. The one on the far right is the correct one for the glitch. See how its roots stick out? You have to run and dive at those roots. If you are partially underground, you did it right. Simply slide down and you end up underwater. It doesn't work with Yoshi, as he cannot dive at the tree, and Wario is too short. Now, there are several things you can do from here. First, you can dive way down and resurface after you swim past the castle, and you can swim and dive back there, even though the water disappears! No idea how far out you can go before you die. If you have not drained the moat, there are two more glitches you can perform. First, simply swim over and touch the cannon. You can then get to the top of the castle with only 8 stars (unlock Mario)! Also, you can walk like normal underwater! And, whether or not you have drained the moat, you can get stuck in Dark World 2.0!

Why it works
Glitch itself: The tree's collision zone extend further underground the most people think. Normally you automatically jump off when you touch the ground. If you hit it right, though, you grab on and are halfway underground. Sliding down results in you leaving the tree itself, and you fall into the plane of water that extends around the castle grounds.

Behind Castle: If you leave the water without jumping or hitting a slope, you can continue swimming, even though you aren't in the water.

Credit
Original method found on GameFAQs FAQ, infinite water found by Uberninja1337.