Pakistan is not in the Middle East but unfortunately close enough. Remember what Canada's Mark Carney said: Either at the table, or on the menu. He was absolutely right in this new World Order of the Law of the Jungle. Pakistan's only real enemy is India and that's a huge threat. Never underestimate that! But Pakistan must and actually does put some checks on Israel to not get too much in bed with India. The recent deployment of Pakistani jets and 13,000 troops in Saudi Arabia is at least partly a message to Israel from Pakistan.
So, no, as much I wished Pakistan stays out, it just can't. Geography dictates Pakistan's involvement in the Middle Eastern affairs.