The agreement is a major reversal for Democrats who had narrowed their ambitions for the package to addressing looming lapses in the Affordable Care Act and changes to prescription drug prices.