“...what’s the most effective way to avoid flat tires?”
Use Quality Tires and quality tubes and do not ride where rainfall has washed debris from the road to where your tires are riding through. This debrie field is where things like nails screwdrivers screws and other things attract collect after heavy rain and tires (all tires) will pick it up. I also used to use tire scrapers which I can’t seem to find any longer as brake mounting systems have changed.
What do the mountain bike riders use?