It's mainly because of Putin's naive, underlying belief in Ukrainians and Russians being one people that he didn't transition the Russian army into a proper war footing until after the first phase was already over. He thought that it would turn out like Crimea circa 2014 except just a bigger version.
Except it didn't go that way at all and Ukrainians in western Ukraine and Kiev are actually quite anti Russian in their views. They have this narrative about Russians / Stalin being domineering towards them and want closer relations with the west / EU.
Another reason is because Russian pilots never trained as extensively or as many hours as western equivalents. I also hear that Russian pilots are not given freedom of range, they're just given specific mission perameters and a specific route and that's it they must follow it to the letter.
So a few years ago apparently Chinese flanker pilots held a competition against Royal Thai pilots with Gripens. From what I hear the flankers annihilated the gripens in close combat but the 2nd day when it was BVR with no rules, the flanker pilots got thrashed. Some claim that it's due to the flanker pilots not knowing the terrain as well as the Thai's and the Chinese flanker pilots tended to act robotic, they would naively fall into simple traps. They basically hadn't been taught to really think outside the box and be creative.
People also tend to underestimate just how many mobile air defense systems the Ukrainians have in service. Remember Ukraine was the frontline of the USSR with NATO aside from the Warsaw PaCt. As a result, when the USSR imploded, the Ukrainians ended up keeping hundreds of mobile platforms. They got 250 S-300 batteries, Kubs, Osa, etc way too many to name + look at how much money the US/NATO have thrown at them. The US has given Ukraine more money than Russia's total military budget. No matter how you want to look at that, it's no joke.
Anyways for myself, the F-5, even during the Iran-Iraq war, it was a secondary aircraft with a support role, so to claim that an upgraded F-5 is superior to a SU-35 with thrust vectoring, uhhh... no...sorry I'm not buying it. Honestly if Iran were to exchange some drones and missiles + some cash for a few dozen flankers, especially SU-35s, I think it would be a great deal at a great value.
Ask yourself, How many fighter jets do they still have left that can drop dumb bombs?
Until they solve PGM problem they will continue to lose aircraft