Many U.S. states have been slow to improve their finances nine years into the economic expansion. That raises a risk they won’t be prepared when another downturn hits, making them susceptible to big spending cuts that make that next recession worse.

State governments have been grappling with tepid revenue growth and heavy pension and Medicaid costs.

In...