News reports and a 2007 medical study show that about three to five children die in the United States each year when a sand hole they are digging collapses on them.
There shouldn’t be a law against digging the hole, but a policy against leaving the hole would be good to have. Either way it would be difficult to enforce so people need to keep an eye out for where they are going as usual. You could step on a manowar, glass, trip on beach wood, there are all kinds of hazards that require someone to see where they are going on a beach. People like to dig holes and should be allowed to, but not leave them.