I'm old enough (53) to remember when public school yards weren't fenced. They used to just be the after-school defacto parks, where you could go to use the monkey bars, jog the track, shoot hoops, etc... But along about the mid to late 1970s, the fences began to appear.
It's exactly as NY Charlie says: Nothing to do with md'ing per-se, but everything to do with legal stuff. Example: A young couple had taken their toddler to an elementary school in the Los Angeles basin during the afterschool hours, to the tot-lot. They were pushing the toddler down the slide. The toddler falls off the side, and is greviously injured (broke his neck or something). The parents sue the school AND WIN !! Can you believe that ? Well guess what happens next? All the schools around the entire southern CA area get fences around the schools.
However, with all that said, the signs too are .... uh .... "obligatory". You know the boiler plate stuff about "visitors check in at the office" or "no trespassing, permission to pass revokable, private", etc....
I'm not sure about the rest of the USA, but here where I'm at, there's always still a propped open gate, and ..... despite the ominous signs, persons still use the school yard after hours (walk their dog, fly a kite, etc...). So I'm of the opinion that the signs and fences are there to deflect lawsuits, or to usher you on if you were *really* being a nuisance of some sort.
I can't speak for the ones that are truly buttoned up like Ft. Knox (with no entry points). But if I see that others can and do routinely go in for other purposes, then I will consider myself just as innocuous as them.