Hitler’s order to kill Russians instead of taking them prisoner created a “fight to the death” situation. The mass surrenders stopped and the Germans found themselves fighting a stronger Russian army.
Vacillating between Leningrad and Moscow didn’t help either. He got neither.
He could have made a deal with Ukraine, similar to what he did with Slovakia. Basically a puppet state but pretty much leaving the Ukrainians alone, and even allowing them to exact revenge on the Russians. Most Ukrainians would have welcomed it.