The Democrats seized control of both chambers of Congress, securing potentially sizable majorities in the House and Senate within hours of polls closing.