So you ask, "Why do jet engines with afterburners use variable area nozzles?"
Such engines might be for military or commercial use, but are used to propel the aircraft to supersonic. The Concorde was an example of a non-military supersonic aircraft, the engines on which were afterburning.
There is one basic reason why the nozzle area changes, and it is "to maintain engine airflow."
Nozzle Performance for convergent nozzle:
A nozzle performance plot shows the flow parameter -- Wg·Sqrt(Tt)/[Pt·A] -- versus nozzle pressure ratio -- Pt8/Ps8 where:
Wg = airflow, plus combustion by products, hence vitiated air
Tt = total temperature
Pt = total pressure
A = area at nozzle throat
Pt8 = total pressure at the nozzle throat
Ps8 = static pressure at the nozzle throat
reaches a maximum at M = 1 (nozzle throat Mach number = 1).
The value of the flow parameter is around 0.5318.
WgSqrt(Tt)/[PtA] = f(M,k,R), where
k = specific heat ratio,
R = gas constant
Without Afterburner
During dry operation at 'military power', the engine is at it's design point, at 100% compressor speed, & turbine design point if the compressor & turbine are designed to have a good match point (thermodynamic & aerodynamic).
At this point the flow parameter at the nozzle throat is at its max ~= 0.5318.
With Afterburner
If the afterburner is started, then the total temperature into the nozzle, Tt8, increases sharply. Suppose the temp doubles?
then Sqrt(2·Tt8) = 1.4·Sqrt(Tt8), and you have 1.4 times the choked flow parameter at the throat.
But the flow parameter cannot increase, so what happens is that the airflow decreases by a factor of 1.4. And just where does this airflow come from? From the turbine exit, which comes from the burner exit, which comes from the compressor exit, which comes from the compressor inlet.
What happens next? An engine surge if the FADEC (Full Authority Digital Electronic Control) tries to maintain compressor rotor speed by increasing fuel flow to the burner in order to increase turbine output. Actually, this could result in a turbine over-temp, so the FADEC has to cut back on the demand.
As well as lighting the afterburner causing Tt8 to increase, it causes a decrease in Pt8 ... there is a drop in pressure that is due the heating. This is a Rayleigh process, and accounts for the 'hot losses'. In an A/B (afterburner), there are frictional or cold losses, but these are minimal in comparison to the hot losses. These total pressure losses also cause the flow parameter to increase, as Pt is in the flow parameter denominator, and contribute to the loss in airflow.
The solution to the problem of higher Tt and lower Pt that restricts nozzle flow is to increase the nozzle area -- then all of the engine's other components are happy. Also happy is the pilot who is chasing or being chased by an adversary, and who doesn't want a missile fired up his tailpipe because his engine quit on him.
About the divergent section of the nozzle - it is to expand the gasses to near ambient, and obtain some more thrust in doing so.