There is no shortage of mountains along the LOC either, is there? But terrorists have snuck in through mountains, and they will do it in Af-Pak as well. Heck, there are videos on youtube of Afghan talibs making their way through rocky mountains into Pakistan. (I won't post them here, because they come from jihadi propoganda sources.)
Fencing is a one time cost, but manning and monitoring it is a recurring expense. But anyway, if the alternative is continous war, then it's a smaller expense. I'm just not sure if it is that easy to insulate Pak and Afgh from each other, like India and Pak. One of the reasons is that the people living near the common borders have a lot of cultural affinity to each other, and think in terms of tribal or ethnic loyalties, rather than nationality. Can an electric fence put an end to the two way migration once and for all? In our case, it was a matter of keeping Pakistani jihadists and infiltrators out, not entire populations always migrating to and fro.