It's not rocket science. Both countries attacked the same set of groups (with similar aims, i.e. Balochi secession), across the border in order to absolve themselves from the blame of attacking own citizens.
As you may know, Balochistan is a province in both Iran and in Pakistan. Balochi separatist movements are present on both sides of the border with the same aim: carve a Balochistan out of Iran and Pakistan. Just like Kurds exist as separatists in both Turkey and Iran, as well in Iraq and Syria.