If possible, why the Soviet Union attacked the Afghanistan? And where was she going? To the Pakistan or to the Iran?
The soviets weren't "going" any where.
What the Soviets did in Afghanistan was very similar to what happened in Korea... Before the US got chucked out of Iran in 1979 it was infiltrating Afghanistan, which was a Soviet friendly country. When the Shah was overthrown and the CIA was thrown out of Iran they started moving into Afghanistan.. the Soviets went in to Afghanistan to stop the US creating another Turkey near the Soviet border.
There was never any consideration to invade Pakistan or Iran and it had nothing at all to do with trying to get warm water ports... they already had Cuba and Vietnam and if they asked possibly Indian ports if they were so desperate for such things.
the US claim the Soviets invaded Afghanistan so they could then invade Pakistan and get warm water ports was at best a delusion, and at worst a cynical attempt to recruit Pakistani support for opposing the Soviet presence in Afghanistan.