Their being in a locked yard means nothing if they can overcome those locks, which both dogs did.
A standard rule of thumb, if walking a dog in a safe neighborhood, having pepper spray is a must, for escaped but generally friendly dogs. If there are known large, aggressive dogs, then you need a sidearm.
Likewise, and common these days, any coyote sightings and you need a sidearm. If you shoot a coyote, never approach its remains, as it could be rabid, which is a very infectious disease. Call animal control and stay in the area to fend off the curious.
How about a ‘stun gun’?
That’s what I’m thinking about.