You have identified the problems correctly however, this is how geopolitics works. Ukraine was not able to protect itself... the fact that Russia has been able to obliterate Ukrainian defenses with such disdain shows one thing... It(Russia) was in fact sanctioning or permitting Ukrainian independence... hyphenated as it may have been. However, it was Ukrainian belligerence and change of orbit in to a western security alliance, specifically a defensive one but martial none the less, while simultaneously being expansionist as well.
Is anyone here realistically considering the security ramifications for Russia, by having a major bordering state in either a hostile or even reticent security alliance?
That being said, historically whenever an advanced defense or technologically developed state unraveled it's most prized possessions were it's engineers, project managers and scientists. If Turkiye or Pakistan see any benefit, and want to invest... then invest on the people and knowledge not it's byproduct...
One ship has sailed ... what are you going to do about it is the question.