Is this a valid or legitimate way of comparing countries on traits and characteristics? Country A has 16 million inhabitants and 2.000 MW of solar panel
generated power, also a GDP of $50.000 per capita 

Country B has 160 million inhabitants and  2 MW of solar panel
generated power, also a GDP of $10.000 per capita

Would it be correct to say that country A has two thousand times as much solar
power because: 


If country A was as populous as B, they would have 20.000 MW in solar power. 
But if country A  was as poor as country A, they would have 4.000 MW solar power.  So, after adjusting for differences in population and
wealth, country A still has 2000 times the solar power that country B
has?


Is it correct to adjust for differences in population and
wealth in that manner, or not?

Follow up question: Is there a formal way, when comparing countries or
groups, to adjust for differences in various traits (such as
population size and GDP per capita?)
I have no idea whether there are formal rules, but you can emulate physical scientists and look at the units.

Dividing solar power by population is reasonable, as you get megawatts per capita. Those refer to real quantities. 

However, you are dividing by GDP (in a roundabout fashion). The units of GDP are (currency unit)/(year). Since megawatts are a real quantity, and thus no currency value, the resulting ratio is (megawatts)(years)/(currency unit). This does not appear to correspond to anything.

You could try to fit a model that predicts solar capacity as a function of wealth and population, and the model calculations should implicitly correct the units.