Afghanistan is a problem because of Pakistan. If they actually sealed the border, didn’t aid, arm, and harbor them, then the Taliban would have withered away by now.
The Pakis need to be afraid of us more than they are of wanting influence in Afghanistan.
There’s no way to seal that border... it’s some of the most remote and rugged mountains in the world. Same reason it’s impossible for anyone to bring Afghanistan under unified control - terrain makes power projection so difficult even the most powerful militaries the world has ever known have failed miserably at it.