There was one cause of this and one cause only - 100% stupid, no common sense, unnecessary handling of the firearm which was either never in a proper and safe holster or was removed from the proper and safe holster by the person carrying it. If carried properly, there is no need for the gun to come out of the holster once it is placed in the holster at the beginning of the day until it is ready to be stored at the end of the day, unless, of course, you are intending to shoot someone. And, actually, my firearm is stored in the holster at night anyway so my gun only comes out of the holster about once a week for a condition check. On a rare occasion I might have to store the firearm in my unattended vehicle if I am entering a school building for some reason, but I carry in a paddle holster that is easy to remove from my belt IF you are familiar with the locking tabs that keeps it secure - so in that rare instance the gun still never comes out of the holster when storing or when returning it to my belt.
We can come up with all kinds of ways to prevent the gun from discharging when playing with it when you shouldn't be playing with it - but the one real answer to this one is don't play with the damn gun.