Democratic-led states have increasingly turned to the courts and state legislatures to challenge federal immigration enforcement.