You train your children on how to handle guns safely, and you enforce absolute discipline in the matter. That’s how.
Exactly right. The harshest gun rule I grew up with, one that applied to my kids too, was "any gun safety violation is an automatic ban from shooting activities for a minimum of one year". With the certainty of such a stiff penalty, no one touched a gun without permission or mishandled one when they had permission. I would have been very strict with that penalty if the situation had come up, but I never had to follow through. My kids knew how to handle guns, knew they could handle guns just by asking, and knew they could not handle guns - EVER - without asking and then following all rules perfectly.