These are different capitals and each case should be treated separately. There are few generalities that need to be discussed though, which apply to all five.
You are really asking about the Soviet-era capitals of Soviet Republics (the capital of Kazakhstan was moved in 1997 as you noted), which were by no means independent countries. The decisions on the precise boundaries of the Republics and their capitals (which, at the time, were of no more significance than, say, State capitals in the US or other federal republic) were made in Moscow. How precisely these decisions were made, we do not know, since the relevant archives in Moscow are still closed. We can only make educated guesses. First of all, the official Party line was that in each Soviet Republic the "main ethnic group" should be in a majority, so, the ethnic make-up of regions was taken into account to some degree. Things were not so simple, however, since sometimes, curiously, the Moscow authorities created large ethnic enclaves within the Republics (the most famous case of this is was in Nagorny Karabakh, which, later on, resulted in wars between Armenia and Azerbaijan). But let me not get into this and assume, for the sake of brevity, that the borders did reflect the existing ethnic divisions (otherwise, I will never finish writing this answer).
Next, Soviet authorities inherited some administrative divisions and regional administrative centers from the Russian empire (more on this, below). Even more importantly, USSR inherited Imperial Russian railroads (and, of course, built even more). These railroads were playing a role similar to the sea access that you noted in the OP. [In the same fashion, if you look at Siberian region of Russia, many regional capitals were located along the trans-Siberian railroad, stretched along the southern border.] Another common consideration is the climate, as noted in Pere's answer. There is one more common and rather curious thing that capitals of the Soviet Central Asian Republics:
While the region has no shortage of ancient cities whose history stretches over millennia (Bukhara, Samarkand, Khiva, Merv, Osh), none of these became capitals of Soviet Republics.
I have a guess why, I will mention it below. But it is a guess only.
Based on what I could find, the brief answer to your question is:
(a) Ashgabat was chosen as a regional capital, effectively due to its proximity to the Iranian border. (See below for details.)
(b) For the rest of the capitals, they are close only to "inter-republican borders", which were not real borders at the Soviet times. This proximity was incidental and the location was determined by various other factors.
Below I will discuss
two three of the capitals: Ashgabat, Tashkent and Dushanbe.
- Ashgabat (spellings vary). It was a small sleepy village until 1881, when the region came under the Russian Imperial control. The original administrative center of the surrounding Transcaspian region was on the Caspian sea, at the city of Krasnovodsk (I am sure, you would have approved the location). Then, in 1881, the center moved to Ashgabat.
According to the Wikipedia article about the history of Ashgabat,
The city was officially founded January 18, 1881, as a fortified garrison and was named after the Turkmen village on that site. Russian military engineers platted the garrison settlement "on the western edge of the aul (village) of Ashgabat on the Gaudan (Howdan) road leading to Persia. The fortress stood on a hill 12 meters high, on which was constructed a citadel-redoubt, and below [it], the residential area, surrounded by walls and a moat." Sixty-seven Turkmen families were compensated for the land confiscated from them for this construction.
Russia developed the area due to its proximity to the border of British-influenced Persia. [The boldface font is mine.] In 1882 a wagon road was built through the mountains to Quchan, Iran, which led to increased trade as well as settlement of Persian and Armenian merchants in Ashkhabad. The Trans-Caspian railway reached Ashkhabad in 1885.
Here is the pre-revolutionary map of the region, indicating, importantly, the railroad, connecting Ashkhabad to other important regional cities.
Note also that the chosen (for its proximity to the border!) administrative center was not in the ancient city of Merv which was not that far from the border either. As for why, my best guess is that Russian authorities did not really trust the local population, worried about too many mosques, old narrow streets and preferred to build a town from scratch. As for why they wanted to be close to the border, the answer, I think, is the "Great Game", which, in this case, involved projecting military might across the nearby Persian border. Once you house a (relatively) large number of troops in the fortress, you might as well place a regional administrative center under their defense. Does it make sense to you? It does to me.
In 1925, the region became a Soviet Socialist Republic of Turkmenistan, whose territory closely matches the one of the Transcaspian region, except for the important addition of the ancient city of Khiva and nearby areas, which, during the time of the Russian Empire, was an independent (not really, but never-mind) khanate.
Why did the Soviet authorities choose to keep the same capital as before? Likely, for the same reasons, plus the fact that the density of the Russian-speaking population in Ashgabat was higher than in other places and Moscow authorities still did not really trust the locals. Plus, the fact that, by that time, Ashgabat was the provincial capital for over 40 years, hence, the administrative infrastructure was well-established and did not have to be built from scratch. (The same consideration would apply to Tashkent, discussed below.)
Why did not Mr. Niyazov, who became a Turkmenbashi, a local dictator (pardon me, the father of the nation), after dissolution of the Soviet Union, move the state capital elsewhere? I would advise against asking him or his successor, or making any suggestions. The death penalty in the country was formally abolished in 2008, but who knows…
Edit. Lastly: Try to find a place for a capital of Turkmenistan which is "most symmetric", in the geometric center of the country. Where would it be? It is in the Karakum desert, not an easy place to develop.
- Tashkent. This city is considerably older than Ashgabat, but is much younger than other ancient cities of the region.
According to the Wikipedia article,
In 1809, Tashkent was annexed to the Khanate of Kokand. At the time, Tashkent had a population of around 100,000 and was considered the richest city in Central Asia. Under the Kokand domination, Tashkent was surrounded by a moat and an adobe battlement (about 20 kilometers long) with 12 gates.
It prospered greatly through trade with Russia but chafed under Kokand's high taxes. The Tashkent clergy also favored the clergy of Bukhara over that of Kokand. However, before the Emir of Bukhara could capitalize on this discontent, the Russian army arrived.
The city was conquered by the Russian Imperial Army in 1865 during the gradual push into Central Asia and in 1867 became the capital of the Russian Governate of Russian Turkestan, see the map below (the colored areas):
Note that Tashkent is right in the middle of the Russian Turkestan, just as you would have advised!
The city was connected to the rest of Russia by the Trans-Aral Railroad in 1906.
After the Bolshevik Revolution, in 1918, Tashkent became the capital of the
Turkestan Autonomous Soviet Socialist Republic (TASSR), still right in the middle of the region, which closely matches the pre-revolutionary Russian Turkistan.
Things got weird in 1924, after the dissolution of TASSR which was split into several Soviet Republics. It still made sense to make Tashkent the capital of one of these, since it was one of the largest cities in the region, well-connected by railroads and not too old (thus, not to many mosques to worry about). But which one and of what shape?
First, it was this (see the map below) geometric abomination, which, more than anything, resembles gerrymandered congressional districts in the US, designed to create artificial voting majorities or minorities:
It seems that they simply took the map of TASSR and combined its red-colored region (Bukhara PSR) with a stretch of land to include Tashkent and Kokand (the capital of Kokand Khanate, before the latter was conquered by the Russian Empire). The result became known as Uzbek SSR.
This republic included the Tajik Autonomous Soviet Socialist Republic and with Tashkent at the north-most border. It looks like, whoever created this map, wanted to mix-up very different ethnic groups and historic cities in one region, governed from Tashkent. The latter was, at the time, still the largest city in the region, in 1926 its population was 323,000. (I do not know the numbers for 1920-1930s, but, for comparison, the historic city of Samarkand reached a similar population figure only in 1980s, while Bukhara only had 280,000 inhabitants in 2017.)
Edit. From 1924-1930, the capital of Uzbekistan was in Samarkand. It was moved to Tashkent in 1930. Why? My best guess is that the initial location was due to security concern, since in 1924 the Basmachi revolt was still a major problem and Tashkent was much closer to the center of the revolt, which, at the time, was in the Tajik mountainous areas. By 1930 the security situation improved quite a bit.
Then the authorities decided that Tajiks deserve their own republic. As I said earlier, the archives are closed, so we can only guess. My hunch is that the changes here are related to the Basmachi revolt, which, by late 1920s was limited to Tajik regions and, mid-1930s, was largely suppressed. Thus, the central authorities decided that they can trust the local authorities to control the province.
Thus, in 1938, the authorities carved out yet another abominable geometric shape, still called Uzbek Soviet Socialist Republic, again with Tashkent as the capital:
In the process, they split the fertile historic Fergana Valley between three of the republics (Uzbekistan, Tajikistan and Kyrgyzstan): The orange appendage on the right part of the picture is the part of the valley which was given to Uzbekistan.
For some reasons, Stalin and his Politburo, decided to keep the capital in Tashkent instead of the more centrally located Bukhara or Samarkand. In absence of archival documents, we can again only guess how the decision was made on the shape. My guess is that they still did not trust Samarkand and Bukhara and, besides, Tashkent was much larger.
3. Dushanbe. This is the only case (out of 5 Central Asian capitals) where I could find an explicit explanation for the choice of a city as a republican capital during Soviet times:
Dushanbe was chosen instead of larger-populated villages in Tajikistan because of its role as a crossroads of Tajikistan for its large market served as a meeting place for much of Tajikistan's population. Along with its market, there was a lively livestock trade as well as trade in fabrics, leather, tin products, and weapons. The mild Mediterranean climate was another reason Soviet authorities chose the city as the capital.
See the Wikipedia article here and references therein.
I decided to stop here, since the answer is already too long. The bottom line is that, as far as I can tell, the central Soviet authorities carved the "Soviet Republics" and assigned their capitals at will, with main consideration given to the ethnic make-up of the local population and communication via railroads, with preference given to older provincial capitals, larger cities and newer cities with larger Russian ethnic population. But, until the archives are opened, we can only guess.