US invaded Afghanistan more than 20 years ago and spent $7 trillion and couldn't achieve anything at all there. They were fighting cavemen (literally) who had no airforce, no radar, no missiles, no tanks, so support from any other country, not even half decent weapons.
In comparison Ukraine has a military, has airforce, radars, tanks, missiles, and receives billions of dollars of support.
The goal was never to occupy entire Ukraine. The goal was to annex east and south of Ukraine that are strategically important to Russia and leave the rest. Half of Ukraine doesn't want Russia while the other half does. They can never rule over that first half, so they would remove Zelensky with someone who that other half can accept but is at the very least anti-NATO if not pro-Russia. The first part of the plan is already over.
Funny enough, this is similar to what US tried to do in Afghanistan and failed because unlike Ukraine, nobody wanted US in Afghanistan so they were kicked out in defeat.