OK, I'm sure I'm not the right person to offer an answer to this question, but the answer for us so far, is "not yet, at almost 6 years old". They seem to have new reasons almost every year for pulling stunts like that. First, they don't know the rule, then when they're a bit older, they test the rule to learn it, then they know the rule but find new independence that they're testing out (my 3.5yo just wants to do stuff that big kids do, that's often why he'd run off). Then, they eventually develop more of an "attitude" where they know they're testing YOU. Or like the PP said, with a friend they are feeling out that new relationship, doing things together they wouldn't alone. At almost 6, I have no idea why ds1 runs when I say no sometimes, but it does happen way less than it used to.
So, totally unhelpful, just know that in my opinion it's not unusual to lack that control at 4.