You have a very valid question.
ISIS army walking all the way from Syria-Iraq to Pakistan, without passports is only possible when Iran regime is fully on board ISIS drama, if such is the case than Iran would preferably send ISIS directly to Afghanistan.
If ISIS had come to Pakistan with fake Pakistani passports, still they need to have exit stamp on passports, which is only possible when equal amount of people are travelling from Pakistan towards Iran, in this case it's gross negligence of Pakistani intelligence agencies.