/u/TheFairyGuineaPig has a good answer here
Also in the case of Pakistan the name actually came from a abbreveation of the provinces of british India that were majority muslim. The Idea was suggested by Choudry Rahmat Ali when he said that the provinces of (P)anjab, (A)fghania( is now Khyber Pakhton Khwa), (K)ashmir,(S)indh and Balouchis(TAN) (was TAN just cause paksb sounds weird). And Choudry found it funny enough that by adding an I in the middle it would mean Country of the Pure in poetic urdu (which was pretty much farsi then)
Also I would like to differ somewhat with the previous response (the linked one) because for at least 600-700 years India(also called Hindustan), Pakistan, Afghanistan have pretty much been under constant persian Influence. From the Tughlaq dymasty to the last Mughal Padishah all the rulers (of most of the area) used Persian as their Court language even though most of them were of turkic origin. This left a lasting impact that changed the languages of the subcontinent heavily. Hindi even had a lot of Farsi loan words but farsi loan words were removed after partition. Urdu still uses persian words everywhere. Also like a decent amount of Afghanistan speaks Dari which is pretty much Farsi. Also Hindi contained a large amount of Farsi loan words until Partition.
And for the central asian countries, they were now and then controlled by persian rulers, but the dominace of persian culture(art and stuff, even a bit of language) was the main reason they adopted the suffix "stan". Also remember these central asian nations used to be hordes, and hordes are generaly known to adopt the culture of settled people when they conquer them. Sorry the Central Asia part is a bit vague cause I know less about the area. Thanks u/Wolffanghameha