There are a number of circumstances where bear spray is at a disadvantage to firearms including environmental factors like wind, rain and cold temperatures.
Know the product! Winds, rain, snow, freezing temperatures and age of the product all play a role in the effectiveness of bear spray. If it’s expired, properly dispose of it according to manufacturer's recommendations and replace.
Source
Also be aware that extreme heat or cold may affect the performance of the product. Canisters have been known to explode if left in a vehicle in summer. Each canister also has an expiration date.
Source
Like a strong wind, hard rain requires a forceful spray to compensate for the elements.
Source
Sometimes bear spray won't stop the bear or even cause the bear to react.
A lone female grizzly bear reportedly surprised a man hunting elk at Big Creek north of Gardiner on Oct. 28. The hunter reported to Montana Fish, Wildlife & Parks that he came upon the bear feeding on a carcass in the brush and that the bear charged him. The hunter said he first used bear spray to deter the attack then shot the bear in self defense.
The second incident was reported on Oct. 31 by a group of elk hunters who said they came upon and surprised a female grizzly bear with two young bears at Johnson Lake near West Yellowstone. The hunters said they first used bear spray on the charging bear but, as the bear continued to approach, they reportedly shot the bear in self defense.
Source
U.S. Fish and Wildlife Service biologist Brad Benter, who has experience with spraying several bears that barely responded, describes spray as “better than nothing,” but warns people need to be aware it might not work very well.
Twice, Benter said, he has sprayed bears in the face from as close as six feet and solicited only a minimal reaction. In one case, he said, the bear backed away from the weatherport into which it had been peering. In the other, the bear just ignored the spray.
In neither of those cases did the spray spark aggression, but “it wasn’t like the bears went away,” Benter said.
Source
During a recent interview with TIME, Orr described how he first spotted the grizzly bear and her cubs while he was hiking through Madison Valley to scout for elk. The next thing he knew, she was charging full speed at him, he said.He used his bear spray, which generally deters aggressive bears, but the grizzly jumped on top of him, biting his head and arms before walking back into the woods.
The Montana native says he then got up and began to jog back to his car, which was about three miles away. Ten minutes later, she was back, he said. This time, she bit his arm and shoulder before standing on top of him to make sure he was no longer a threat. Orr eventually managed to get up and hike out the rest of the way to his car.
Source
When people talk about bear spray being more effective in studies they are usually referring to this one Efficacy of Bear Deterrent Spray in Alaska and yet,
In Tom Smith’s bear-spray research, just 10 of 72 bear-spray incidents involved charging bears. Most incidents involved curious or non-aggressive bears. In contrast, his gun study examined bear attacks only.
Source
People will say that in the study the people who used bear spray were uninjured compared to the people who used firearms, but since people have been seriously injured while using bear spray, it seems that the data is incomplete.
To put bear attacks in perspective, you are far more likely to be stabbed/robbed/murdered/raped by the two legged creatures you encounter and yet lots of people don't carry weapons to prepare for that eventuality. So I am not sure that I would say that the guides don't carry firearms because they are confident of not needing the them.