As I read your request, a picture comes to mind of an energetic, curious and creative little boy. (I actually see this in all children.) And I see a sea of sand, begging to be played with. Irresistable. As a playful adult who has learned to anticipate unwanted behavior in the kids I've had in my charge, my first thought is, "Hmmm, what can the kids do that's right so they won't do what's wrong here?"
It's fine to tell a child what he can't do and why, but it's so much more effective to suggest what he CAN do. Get him involved with his own ideas – he'll stick with those with more enthusiasm. Help him make up games that involve running, jumping, and rolling in the sand, or pushing it into hills and jumping them flat, or drawing targets in the sand and throwing shoes or other toys at the targets.
And then, of course, if he does descend into forbidden activity, he shouldn't get more than one warning before you leave. If you don't leave (or follow other named consequences) every single time, you will have a son who pushes boundaries every single time to see whether "this time" will be one of the lucky ones where you'll tolerate his misbehavior.
Your son might be one of the exceptionally spirited and defiant ones. It's impossible to tell from here how much of that is his basic emotional makeup, and how much of it is parenting mistakes. But let's assume you just need better ways to deal with his desire to do things his way.
I strongly recommend the most practical and effective parenting book I've ever used, and I've relied on these techniques for the past three years, since my grandson was 2.5. Get yourself a copy of How to Talk So Kids Will Listen, and Listen So Kids Will Talk, by Faber and Mazlish.
Learn how to make your child part of the problem-solving team. Kids can be remarkably good at it, and are highly invested in solutions that they understand and think of themselves. This stuff works. It takes a bit of practice at the beginning, but it works!