The department, in a highly unusual lawsuit, argued that confusion over candidates with similar names could taint the election result.