As a complement to the previous answers and especially Tom Au's answer here: it may be just a general hypothesis, but a very intriguing one.
This transfer of territories between Soviet Republics may serve the general purpose of binding together these republics by including them in a logic dominated by the central authority, by diluting traditional boundaries and identities and by creating at least potential territorial rivalry where the central power in Moscow could play the arbiter.
I have found a map of these territories here, where this situation is described as a breakaway territory strategy.
The "breakaway" territory acts as a "glue" that keeps the different republics together. (The larger the disputed property, the longer and more difficult the divorce procedure.)
As for Crimea, for all of these territorial changes and/or disputes other specific/local reasons may be found, but I think that all these cases may be considered through this logic.
In the case of Ukraine/Russia, territories had been also transfered from Ukraine to Russia, as seen here.
On the same map is mentioned the transfer of Ukrainian territory to the Moldavian Soviet Socialist Republic, namely Transdniestria, which was not historically Moldavian. That is illogic outside the context described above, especially as other historically Moldavian territories remained part of Ukraine (Budjak and Northern Bukowina).
Abkhazia and Ossetia had a tradition of autonomy within Georgia and Nagorno-Karabach was an Armenian enclave in Azerbaidjan, and Soviet central power has supported their autonomy within the same logic.
It is also interesting to consider this within the larger scope of the relation between the Soviet internationalist-imperialist central power in Moscow and the local & national authority of the republics. The disputed territory could be claimed as pertaining to the larger more universal authority of the Soviet empire.
As an arbiter, Moscow could intervene but also could claim directly for itself (that is, for Russia), territories disputed between the republics. Also, most of the aforementioned territories had Soviet military bases and/or now have Russian military bases, and the causality between being disputed territory (with "gluing" properties) and having military bases works both ways.
Russia has been constantly expanding since XVII century.
is not correct. XVII = 17th century. The sale of Alaska in 1867 and the loss of Finland after the Russian Civil War (1917 - 1922) come to mind as prime counterexamples, not to mention the loss of Central Asia and many Eastern European states after breakup of USSR (1991). Those were some fairly large losses of land---shrinkings, not expansions.