This is a terribly sad situation for the members of that family, especially the child that pulled the trigger.
Unless this firearms' owner left it unguarded with evil intent, this is a failure of the firearms' primary safety.
It could be a revolver or striker fired pistol, or have a cross-bolt safety, tang mounted safety, lever safety, trigger lock, cable lock, mag well lock, mag removal, ammo under separate lock/key, visual chamber check, pinky chamber check, chamber flag, lockbox, gun box, gun safe, gun vault, RSC, et al…None of these would've prevented this shooting once the weapons's primary safety failed.
It all comes back to the owner or user, if of an appropriate maturity level. He/she is the firearms' primary safety. Everything else on the list is little more than a tool to enhance the ability of the owner/user to verify/maintain a firearms' inert status when not in use.
The weapons' primary safety failed. That's all it took. How terribly sad...