score:9
In any war, the strategic goals (and logistics) of the war defines what is worth doing and what is not. The same is true of sieges.
Environment: Pre-gun fire, the only way to raze a city was to (maybe sack it first and) burn it to the ground. Urbanisation of the country side moved more people into cities making them bigger. Now, guns could destroy large portions of a city but not fully. There should be cover, sneakaways, places to hide either bombs or snipers or small units for ambushes. Even fires would stop and not travel as far as they used to -- steel and concrete do not burn that well. So, you have more people and an environment where they can fight effectively. Add to this easy to use weapons (see below) and you the means to do effective urban warfare.
Strategic goals: Now, both Stalingrad and Warsaw were highly political targets that both sides really wanted to keep. Stalingrad because it was Stalin's City and losing it would have been a propaganda disaster. Warsaw because it was the Polish government's in exile (in London) way to assert control over Liberated Poland against the Soviet Union (veiled?) attempt at conquest. Keeping or liberating the city were war goals worth of the nightmare of getting into urban warfare.
As ever, it comes to the overall strategy of the war whether a battle is worth it or not.
A modern example: In more modern times, Baghdad fell to armoured divisions which was thought to be utterly impossible. Again, the goal of the defenders was to flee and create a civil war, not fight for the capital. Thus no major urban war within Baghdad happened. Maybe that helped with the above statement, maybe not. It's too early to tell. Was Baghdad seen as a strategic goal by the US? Yes. Was it seen as a strategic goal by Saddam forces? Maybe. Was it seen as a strategic goal by Al Qaeda? No. Again, it comes down to overall strategical goals.
Side note: Finally, firearms are much easier weapons to use than swords, bows, spears, crossbows, and co. They require limited expertise (thus why the Kalashnikov is so popular because it is so simple) which you can train easily. Its effects are hard to protect against. It takes a few minutes to be able to shoot, a few days to become competent. Thus your civilian population can learn to defend itself really quickly. Explosives need good bomb makers, the delivery system can be dumb -- see suicide bombers, IEDs, mines, etc...
Upvote:4
Modern vs. medieval: it's a matter of cover.
If you're facing someone with a sword or a pike, cover gains you little in the way of protection: an attacker can simply approach, reach around the cover, and stab you. In contrast, height gains you a great deal of protection: it's hard for an attacker standing below to reach you, but you can drop things on them, or reach over a low barrier you're standing behind while the attacker can't reach up and over. The city walls provide you with a great deal of height, but once they're breached, the cover provided by an urban environment gains you little.
In contrast, if you're using a gun or a grenade launcher, cover provides you with a great deal of protection by stopping bullets, while an attacker without similar cover is an easy target. Height, on the other hand, just makes you a bigger target. City walls function mainly as a mechanical barrier to advancing troops which can easily be countered by heavy artillery or combat engineers, but the city itself provides a seemingly endless supply of cover.
Stalingrad vs. Kharkov: it's a matter of objectives.
During the Battle of Kharkov, the Soviets were fighting a delaying action while they evacuated the city (including its industrial facilities). Once they'd finished that, the city itself was a strategically untenable position, so the Soviets retreated.
Holding Stalingrad, on the other hand, was a matter of vast pride to the leaders of both side. Thus, they kept throwing men and materiel into the fight long past the point of diminishing returns.