The White House defended its record, saying it responded to the 2019 exercise with an executive order to improve the availability and quality of flu vaccines, and that it moved early this year to increase funding for the Department of Health and Human Services’ program that focuses on global pandemic threats.

“Any suggestion that President Trump did not take the threat of COVID-19 seriously is false,” said Judd Deere, a White House spokesman.

But officials have declined to say why the administration was so slow to roll out broad testing or to move faster, as the simulations all indicated it should, to urge social distancing and school closings.

Asked at his news briefing on Thursday about the government’s preparedness, Mr. Trump responded: “Nobody knew there would be a pandemic or epidemic of this proportion. Nobody has ever seen anything like this before.”

The work done over the past five years, however, demonstrates that the government had considerable knowledge about the risks of a pandemic and accurately predicted the very types of problems Mr. Trump is now scrambling belatedly to address.

Crimson Contagion, the exercise conducted last year in Washington and 12 states including New York and Illinois, showed that federal agencies under Mr. Trump continued the Obama-era effort to think ahead about a pandemic.

But the planning and thinking happened many layers down in the bureaucracy. The knowledge and sense of urgency about the peril appear never to have gotten sufficient attention at the highest level of the executive branch or from Congress, leaving the nation with funding shortfalls, equipment shortages and disorganization within and among various branches and levels of government.