Is it ever OK to discipline your friend's kids?

I spent this past weekend with my best friend Natalie, a woman who I've known and been close to since I was 8 years-old. Beyond all of the childhood memories we lived through together, our friendship grew even deeper in high school and college--we attended the same schools and saw each other almost every day for nearly a decade. As adults, we've been bridemaids in each other's weddings and I'm her son's godmother. I can call Natalie at any time, with any problem. I tell her pretty much everything, and I'm quite certain I'll know her until I die.

But I can't discipline her kids.

I figured this out on Sunday. I was visiting while Natalie's husband was away for work and she was home alone with her 9-month-old baby and 4-year-old son. She had already explained to me that the mood of the house, unless she times everything correctly, can quickly devolve into chaos, with the two little people needing things, becoming inconsolable, and screaming or running around or throwing a tantrum or worse. (Is this the time to tell you I don't have kids? Yeah, not yet.) At one point, the baby was yelling because she needed to be changed and, for no reason I could discern, my godson came over from playing peacefully on the floor and began yelling in my face, echoing his sister's cries.

"WAAAHHH-WAAAAAAHHH," the baby shrieked as her mom got tangled up in the buttons of her onesie.
"WAAAAAHH-WAAAAAAAAAAAAAAAHHH," my godson screeched, now standing on the table to better reach my ear.
This went on for perhaps 37 seconds before I looked my godson dead in the eye and said in a stern voice: "You need to stop. You need to stop right now."

He did. But I saw the look on my friend Natalie's face and it told me I had crossed a line. I didn't bring it up and neither did she, but the rest of the afternoon was strained and a little weird and I made sure not to interfere again.

Though I'm still not entirely positive that I did anything wrong (I mean the kid was violating my personal space and acting up, and I simply told him to stop), I suspect there's some etiquette surrounding parenting I don't yet understand. There must be a rule that says you're not supposed to reprimand other people's kids, even if those kids are being obnoxious. It's not the first time I've run into this problem. Last year, my husband and I were sharing a beach house with friends and one of the couples had brought their 4-year-old son. We were sitting on the fenced-in, slightly raised, slightly precarious wooden deck, and the boy kept unlocking the tall wooden gate, slamming it behind him, and running away. There were all sorts of not safe things within steps of where we were: an ocean, an unlocked construction site, wild deer, drunken strangers. But it kept happening--unlock, slam, run; unlock, slam, run--and his parents kept gently asking him to stop, to no avail. When the parents went inside, and the boy took an extra long time to come back, my husband (then fully bearded and slightly menacing looking) got nervous. So, he stood up, opened the gate, and said something to the effect of: "This is not safe for you. You can't keep playing like this. You have to come inside." The little boy cried, and we looked like jerks.

Here's the thing, I have no desire to tell other people how to parent, but when their children are behaving in an unacceptable way, what's a non-parent adult to do?

Do you let the kid scream in your face? Do you allow a 4 year-old to wander into potential danger on your watch? I'm honestly perplexed by how to behave in these situations, but I'm sure everything I've done up until this point has not only been wrong, but somehow offensive too.