It mostly wasn't, except in reconnaissance, but that's down to the ineffectiveness of strategic high altitude bombing up through WWII regardless.
In terms of the ability of zeppelins to, say, drop bombs on London during WWI and not get shot down, there are a lot of factors involved. One is that the zeppelin and lighter than air craft were very slightly more mature a technology in WWI than winged aircraft. It may not seem like much, but given that the start of WWI was barely a decade after the very first flight of an airplane, it made some difference. Additionally, zeppelins have the benefit of carrying capacity, and could carry several tonnes of bombs each, which meant that even a very small fleet of them could deliver as much bomb tonnage as a much larger number of planes could.
The early years of air to air combat also advantaged zeppelins fairly well. Without radar and all of the developments we are familiar with from the WWII era and onward, including centralized radio control and communications, it was challenging for planes to even find zeppelins, especially at night and especially given the very small number of planes in any given air force at the time. Moreover, because of the weight advantage of zeppelins they tended to be much better armed than the planes attempting to intercept them. You have zeppelins which would have multiple machine guns that are individually manned fending off fairly slow completely unarmored airplanes that were basically made out of primarily paper and fuel, not the sort of thing that you want to get pierced by machine gun fire.
And while it may seem that enormous bags of flammable Hydrogen would be supremely vulnerable, that's actually not quite the case. In the typical scenario where you shoot a bullet through a Hydrogen gas bag the result isn't an explosion, it's just a slow leak of gas, and then the zeppelin has to dump some additional ballast on the way back home and requires some repairs. This is because ordinary bullets don't tend to cause fires and also because Hydrogen is only flammable when combined with Oxygen, a small leak of Hydrogen is not a particularly great fire risk on its own. It took the development of special incendiary and explosive rounds designed for taking out zeppelins specifically for that to change.
In that case you have two possible mechanisms of action. One is you have an incendiary round that pokes a hole through a gas bag, and, hopefully, catches fire to a very small amount of Hydrogen mixed with Oxygen at the entrance or exit (unlikely) or catches fire to the edges of the holes it makes passing through (possible). Then a small fire as the gas leaked out of the cell could potentially burn the edges of the hole, causing it to expand into a wider hole which releases more Hydrogen and then escalates into a widespread fire. The problem with this is that there are lots of forces working to blow out the small fires (such as the wind blowing across the zeppelin's fabric and so forth) and also because the pressure inside the gas bag is very close to atmospheric pressure, so the leakage from a small hole would be slow, and a slow leak means slow mixing of Hydrogen and Oxygen, which means you don't have the ingredients for a fire. The other kind of round was one that exploded and caught fire just after penetrating the fabric of the zeppelin. And this is vastly more effective, because it creates a big hole, it creates very rapid Hydrogen and Oxygen mixing, it starts a very robust fire burning immediately, and that fire is very likely to spread incredibly rapidly and consume the entire envelope of the zeppelin.
By 1916 Britain's airforces had developed some solid defensive measures against zeppelins. Through the use of search lights, coordinated actions, and special rounds they were able to take down 3 zeppelins in that year alone, which is a significant chunk of what was a very small fleet of air ships (on the order of a dozen at any given time). In 1917 zeppelins were forced to higher altitudes and restricted to the most favorable flying conditions to give them the best chances of survival, even so several were downed by defensive fire and several more downed by mechanical problems or adverse weather. In 1918 there were only a few zeppelin bombing runs, though still one air ship was downed. Meanwhile, zeppelin bombing had become increasingly ineffective due to the difficulty of bombing from high altitude and under constant harassment from defending air forces. In 1918 there was a higher death toll among zeppelin bomber crews than there was on the ground from the bombing raids themselves.
So overall, there was a brief window of time where zeppelins had an advantage and could pull off bombing campaigns effectively without much risk of being down by defending forces. And this was due to the fact that air to air interception, tracking, and combat hadn't been developed or matured yet. Moreover, the weight advantage meant that a small fleet of zeppelins could drop lots of bombs, and they could field perhaps half a dozen up to ten machine guns per (as on the R-class zeppelins) which was a formidable defense against intercepting planes. However, it was only a matter of time before the tables were turned and the inherent vulnerabilities of zeppelins (large size, slow speed, vulnerability to fire) were exploited thoroughly by those defending against them. After that airships were primarily used for reconnaissance in war, in situations where they didn't have to brave enemy air defenses.