The Democratic Party and liberal-aligned groups have poured money this year into legislative races in traditionally red states and are poised to finally win statehouse majorities.