You can't completely avoid getting flat tires, but you can absolutely reduce the chances of it happening.
The easiest way to do that is to periodically check on your tires to make sure they're filled with air to the correct PSI.
Most passenger cars recommend 30-35 PSI, but if you have a custom wheel and tire set up, it could be slightly lower. You can use the Rhino USA Tire Pressure Gauge to read your PSI and then add air accordingly. Plenty of gas stations and convenience stores have free air pumps, but if you want your own portable pump, I recommend the EPAuto 12-volt Portable Air Compressor. It plugs into a 12-volt socket/cigarette lighter and has a built-in tire-pressure gauge.
Another important step is to rotate your tires regularly.
Depending on your car being front-wheel drive or rear-wheel drive, your front or rear tires will wear out quicker than the pair that's not under power. By rotating your tires, you can lengthen their lifespan and prevent blowouts from badly-worn treads. You can schedule tire rotation services on Amazon or at Pep Boys — or, since you now know how to change tires, you can do it yourself.
It's worth noting that tire-rotating is only applicable to cars that have the same wheel and tire specifications in the front and rear of the car. You should not rotate your tires if your car has a staggered wheel set up, meaning that rear wheels and tires are bigger or wider than the front.