President Joe Biden signed legislation Saturday to allow the U.S. government to continue accruing debt while imposing caps on federal spending—closing out a chaotic and politically divisive chapter of the 118th Congress that ultimately ended in a bipartisan compromise.