The primary languages of both Afghanistan and Pakistan belong to the Indo-European language family—specifically its Indo-Iranian branch.
Both are Eastern Iranian languages within Indo-Iranian.
All these languages trace back to Proto-Indo-Iranian, spoken by nomadic peoples in the Eurasian steppes (~2000 BCE). This diversified into Iranian (Pashto, Balochi, Dari) and Indo-Aryan (Urdu, Punjabi, Sindhi) branches. They share grammatical structures, core vocabulary, and sound patterns reflecting this common origin.
While other language families exist in both countries (Dravidian: Brahui in Pakistan; Turkic: Uzbek, Turkmen in Afghanistan), Indo-European languages dominate demographically and officially.