I think it varies, and I'm not sure there are laws about it. At least there aren't around here. I think it's more common practice or the rules of the particular place. What are you looking for? The YMCA locker room, the store fitting room, or what? What experiences have you had already that prompted the question?
This is your first post here so we don't know anything about you, the ages of the kids involved, any special circumstances, etc. I do know that there's a lot of discussion about expanding the age range, because there are so many kids with autism or disabilities that make it inappropriate for them to go into their own gender's changing room.
Have you been on other sites asking about this? I wondered because you admonished us up front about keeping sexual remarks out of the answer. Have you been reprimanded before? I think there is a lot of pushback against people who are trying to make kids appear to be sexually inappropriate - and most locker rooms and bathrooms have toilets and changing areas with doors where people can disrobe in privacy. The biggest problem is bathrooms with men standing at urinals, but otherwise there are stalls.
I agree with B that family changing areas and bathrooms are becoming more in demand, partly for kids and partly for adults who require assistance from a family member of the opposite gender or those with disabilities or dementia who are accompanied by professional personal care attendants.
If you are a member of a gym or Y where this has come up, you can address it with management and see what accommodations are already being made to allow for everyone to obtain services in safety.