There is special fencing so you can literally fence in your entire yard (if you have fencing) so your cats can roam around in your yard free, but cannot hop the fence. The fencing curls inward so they cant get over. But it's very expensive to get.
I trained my cats to stay by me when they go outside. There is no busy roads where I live, no dangerous wild animals, and no dogs nearby, so as long as they stay on our property they are safe. As kittens I bought them outside in my arms each day, and bought grass and leaves inside for them to smell. Once they werent nervous of all the new noises and smells, I put a harness on them and let them walk around the property smelling and seeing every area, it took a few weeks for them to be comfortable walking on the harness but soon they liked it. I always had windows so they could look out of our house front and back to get familiar with the sights and sounds, and in the nice weather a screen on our door so we had air blowing in during the Spring and Summer. Once they were close to a year they no longer allowed me to put the harness on them, they would chew it and try to get away, so I tried picking them up and when we were outside I put them down and petted them. They stayed right by me as i petted them and I bought a string out so they played with that instead of wanting to wander off. Eventually when I brought them out they would stay by me and never wandered off they sit in our yard and sleep or roll around and come to the back door when they want to come in which is about after an hour and they are happy the rest of the day inside. I dont let them out in bad weather though, like rain, snow, or thunderstorms, and they dont want to go out during that anyway!
If an indoor cat gets out by accident that has never been out, it will panic, hide, or run away. By me bringing my cats out in my arms, they got familiar with the area and it's sights and smells, and what is there "territory" aka my yard, so they had no interest to wander off my property and they had nothing to be afraid of. If they get out by accident, I just wait for them to come to my back door for me to let them in. They act like dogs in that aspect.