In contrast to this situation,
You see contrast only because of your point of view.
You see Ukraine from the PoV of a Ukrainian (the victim) but
You see Afghanistan from the PoV of America (the attacker).
If you change your PoV and stop having double standards you see that the situation in Afghanistan was exactly the same as it is in Ukraine.
The United States can help the people of some country in the struggle for their independence
This is from the PoV of the attackers. Similarly from the PoV of Russia they are sending their peacekeepers to Ukraine in order to help them since Ukrainians just like Afghanistanis are struggling for their "independence"!!!
Americans have helped the people of Afghanistan with everything they could and even fought for them against the Taliban.
You are too naive or brainwashed if you really think that. Do you know how many Taliban leaders has US killed over 20 years? The answer is ZERO. The extremists in control of the country today are the same exact ones from 20 years ago!
If US was really fighting against Taliban then why the hell were they negotiating with them at the same time? And why the hell did they donate $100 billion worth of weapons to them when they were escaping Afghanistan?