It was always a matter of when — not if — a new viral pandemic would make it to America.

We are not immune to global outbreaks, evidenced by previous close-calls with SARS, H1N1 and Ebola. Epidemiologists even predicted the outbreak of COVID-19 with eerie accuracy.

Yet our government was unprepared for the novel virus now upending people’s lives and livelihoods in the United States and around the world. Our health agencies had the information and the resources, so they should have been planning for this, but they weren’t. The problem isn’t because they’re underfunded, it’s that they are bloated and mismanaged.

The core purpose of the Centers for Disease Control and Prevention is to control and prevent the spread of infectious disease. But a close look at how CDC spends its budget reveals it has strayed from this mission of protecting Americans from communicable diseases, turning more toward influencing people’s lifestyle choices.

In 2019, Congress authorized a budget of $7.3 billion for CDC. Roughly $2.5 billion to $3 billion of that was supposed to go toward fighting and treating infectious disease, but most of that was earmarked for existing pathogens — known threats.

This includes $1.1 billion for HIV/AIDS, tuberculosis and other sexually or intravenously transmitted infections and $800 million for an immunization and respiratory disease project aimed at increasing vaccinations against common infections like measles, HPV and season flu.

What about $855 million for “public health preparedness and response programs”? That appears to be mostly a conduit for transferring federal funds ($611 million in 2019) to state agencies during emergencies like natural disasters.

Just over $600 million was set aside for emerging and zoonotic (animal-caused/related) infectious diseases. Of that, only $185 million went toward the emerging type — like COVID-19 — with the rest going to efforts at controlling known diseases, such as Lyme, Prion and Chronic Fatigue Syndrome.

At best, it seems CDC had a paltry billion or so in its budget that might have been used to prepare for a global outbreak. The far larger sum was dedicated to non-communicable conditions.

This includes $1.1 billion for chronic illnesses and behaviors, like obesity, diabetes, smoking and oral health. It also funds projects of dubious value, some already handled and funded by other federal agencies, such as environmental health ($180 million), injury prevention ($270 million), and occupational safety ($330 million.)

The CDC is not alone in this; other national and international health agencies have similarly refocused on chronic and non-communicable health issues.

This is not to say existing diseases and health concerns are unimportant or unworthy of budget dollars. But it’s now a dire problem that precious few tax dollars were dedicated to fighting novel infectious diseases. More important is the effort, attention and expertise these dollars represent, resources our health authorities dedicated elsewhere.

Indeed, prior to the COVID-19 pandemic, CDC and other agencies were busy sounding the alarm about the nonexistent “epidemic” of youth vaping. Collectively, they spent billions on anti-vaping advertisements, biased research and lobbying, wasted countless hours of congressional hearing time, and squandering public trust.

Had they remained focused on infectious disease, might have been prepared to fight real epidemics, like the COVID-19.

How can we fix this? What won’t work is simply throwing more money at the CDC without adjusting how it is spent.

Unfortunately, our leaders aren’t even talking about that kind of change. At the Democratic presidential debate in South Carolina candidates scorned the Trump administration for cutting CDC’s funding, blaming this for making the COVID-19 outbreak worse.

The claim was untrue (CDC’s budget is bigger now than under the previous administration), but it spurred Congress into passing an $8.3 billion emergency funding bill anyway.

Novel as COVID-19 is, there’s nothing new about exploiting a crisis to expand budgets and score political points. Similar claims of inadequate funding were made during the 2014 outbreak of Ebola, for which various health agencies got an additional $5.4 billion. And what do we have to show for it now?

Arguably, emergency funding mitigated the outbreak of Ebola, but it should have been followed by a dispassionate assessment of why agencies weren’t ready for that outbreak and what needed to be done to prepare for the next one. That didn’t happen.

The failure is not of any single administration, agency or Congress. The blame rests with all of them.

The threat that novel infectious diseases pose, both to individual health and national welfare, was known, but our leaders still didn’t make combating pandemics a top priority. As odd as it may sound, we got lucky.

COVID-19 is bad, but it could have been a deadlier virus. While we all wash our hands, isolate and hope for the best, officials — from the White House and Congress down to state and local governments — must work together to adjust our national health priorities.

Agencies need to narrow their focus, stop wasting time and money, and start preparing for the next pandemic.

If they don’t, we may be far more unlucky next time.