If this doesn't just pertain to CoD4.x...
Well, depends on the game. Obvious, I know.
But it boils down to risk-vs-reward. In a game where guns have both range and good stopping power, melee needs a counterbalance to make it something other than a desperation attack.
That usually involves turning it into an attack of opportunity.
A good example for comparison would be the difference between Tribes 2 and Tribes: Vengeance.
Both games have a melee weapon called a Shock Lance. One is a dedicated electrical spear projector, the other is a katar-like blade built into your suit that you can use to stab with any time between your other attacks.
Tribes 2: The Shock Lance is a very powerful weapon, but it's difficult to use simply due to the nature of the game. However, it kills anyone rather quickly, ignores shields, and is an instant-kill regardless of circumstances when you strike someone in the back with it.
In Tribes:Vengeance, the shock lance does little damage, but can be used when you're right up in someone's face, at any time. Kind of like Duke3D's Mighty Boot.
One weapon is a tool for assassinations, the other is more punchy and better used in the midst of a firefight to supplement your attacks. Sufficed to say, the former proved to be more practical in general.