They are "school resource officers". Acting as a guard is secondary. Most of what they do is behind the scenes. They serve as a link between school administration and the DA's office giving advice on legal and security matters to school administrators. They also are in contact with cops on the street are aware of potential problems and prevent issues from getting into the schools.
They might be able to stop, or at least limit the damage from a kid with a gun in the school, but at best might slow down an organized terrorist attack.
So really why would anyone that is a officer or guard work at a school district?
I have some close friends and one relative who work locally as SRO's and a buddy I went to high school is in charge of the program in a neighboring county. I can't speak for all of them, but the ones I know love the kids. And most of the kids really like them. They interact with the kids and put in long hours. It isn't just an 8-3 job. They attend every after school activity, every basketball and football game even on Saturday's. They do a lot to prevent problems, not just react after an issue.