I went to Iceland last summer, and they have a set-up like this....trail, fence...around a boiling mud-pit in a volcanic area. Various tourists stopped off and kids were edging up to the pits. I just shook my head...people don’t grasp the danger involved.
Then there are the times when there aren’t any barriers. I tell my kids - when I say stay away, you figure out how far back is safe, and double it.
That goes for getting near the edges of dirt cliffs and getting close to large ocean waves.
That’s also how you avoid getting hit right above the eye with the edge of a shovel blade because you were standing right behind the guy using it. Which happened to me when I was five years old.
The other thing is training them to “look” with their eyes, and not their hands.