I mean Gaddafi was by many political and social measures somewhat reactionary, due to some aspects of his nationalism, religious orientation (traditional Islam is reactionary; he was resolutely anti-communist and anti-Marxist because of its perceived atheism), as well as traditionalist views of women, despite being more progressive in this respect that that conservative Islamic figures or Islamists. There was an immense concentration of wealth around Gaddafi, although there was also undoubtedly a massive restribution of wealth and improvement in quality of life, I don't think it amounted to a genuinely socialist society. In any case, the meaning of his use of the term 'socialism' was not what Marxist mean, although there were some properties in common.
Ofc you are correct that this becomes irrelevantly weaponized by Western imperialism. The reason Gaddafi was removed was because he was promoting an alterative international monetary system to the dollar, presumably underwritten by Libyan (and allied countries') oil. More generally the anti-imperialist geopolitical policy of the Libyan state clearly played a key role, having targeted foreign capital the moment he came to power. There was probably also a central role being played by the French regime's special forces and intelligence under Sarkozy, as the latter had confirmed links with Gaddafi. A lot of investigative reporting has indicated that Gaddafi was threatening Sarkozy to go public with the fact Gaddafi has brided him. If seems that French intelligence located Gaddafi and likely organized the manpower who actually merked him.