Fire departments are a bit different, in that they probably account at the station/unit level, and the cost of going on fire calls is seen as higher fuel consumption, maybe more coffee expenses, etc… I imagine the air ambulances have a certain level of activity baked into their budget, but there’s almost certainly some cushion or mechanism to go beyond that if necessary.
For the military, there’s probably multiple very dry, very detailed cost accounting procedure manuals and memos that describe exactly how the Federal government, Department of Defense, and individual services account for all their various deployment costs. Beyond that, all of those government agencies employ legions of bean counters to determine that stuff.
If I had to guess, there’s likely a “base” cost associated with a unit, which is some combination of payroll and then some basic maintenance, fuel, etc… costs that are associated with whatever the “normal” level of activity is. That “base” cost probably doesn’t vary much, and is probably pretty much the same across units - i.e. one squadron of F-16s costs much the same as another at the same level of flying, etc… Same with companies of infantrymen, ships of the same class, etc… This is likely modified by where they’re stationed, because of environmental reasons, cost of living differences, supply difficulties, etc… meaning that a squadron stationed in say… Dallas would have lower costs than a squadron stationed in Greenland (but not deployed). And for certain types of units, a certain activity level is “baked in”- helicopters fly so many flight hours a month, ships sail so many nautical miles, and so forth.
I’ll go a bit further and guess that when a unit’s deployed, the accounting is probably done at a different level and from a different budget. So if that squadron of F-16s from Dallas is deployed to some random Polish Air Force field as a show of force versus Russia, then the accounting may be done at a Wing level or higher, and likely comes out of some sort of deployment budget meant to fund the actual deployment of the units separate from their everyday garrison costs.
So for a six month period where they’re deployed, they’re counted as consuming that “base” cost for just existing, and also whatever deployment costs they incur are counted against whatever deployment budget there is.
That’s my guess as to how it works;