Both? Most knobbies have minimal puncture protection, but the knobs themselves can raise the tire casing just far enough from the surface to resist some smallish foreign objects that would otherwise be able to poke through. Even similar-looking tires can vary greatly in their resistance to puncture, based on casing fabric, number of plies, rubber formula, and the presence or absence of an armor belt in the layup.
But flats tend to occur in a very random distribution. Sometimes I can go months without one, and other times I get several per week, just running back and forth to work on the same lanes. Still there are tires I used to favor because of their excellent ride quality and performance, that I don't use anymore because I don't want to fix a flat every time I go out.
All else equal, double casing plies are better, high thread count is better, and belted construction is better at resisting punctures. You can put conventional or tubeless sealant into a tube to afford a little more protection without the mess and maintenance of a tubeless setup.
Thick "thorn resistant" tubes don't have too much of a downside (mostly weight and a little ride quality), but they also don't give very much extra flat protection either.
Tire liners e.g. Mr Tuffys seem to cause flats as often as they prevent them. They chafe into the inner tube at their edges and cut ends, eventually causing air leaks. So advise against those.
I've had some of the same problems more quickly when I tried to use a tire as a liner. The cut edge of the tire (where the wire bead was removed) chews into an inflated tube almost immediately, unless another non-inflated tube layer is used as abrasion protection. That method gets very heavy and yields poor ride quality, to add to the nuisance of getting everything installed just so.
Airless foam tires have the worst ride quality of all, and they're slow and draggy, and heavy, with poor traction, and they beat the snot out of your wheels because they don't distribute loads all the way around like a pneumatic tire.
If you ride on soft surfaces a lot and prefer knobby tires, Schwalbe Marathon Plus MTB and Schwalbe Johnny Watts are both good armored tires that fit the purpose.