Those are known as "Mach diamonds" or "Shock diamonds" (and a number of other names) and are not a characteristic of the afterburner per se but are formed by standing waves in the exhaust when the pressure of the expanded exhaust gases do not exactly match external ambient pressure. They can be formed by either over-expansion or under-expansion of the exhaust gases. The diamonds form at the transition from sonic to supersonic flow which occurs immediately on the "downstream" side of a rocket or jet engine nozzle.
Photo from the link below:
SR-71 Blackbird taking off.
In rockets, flow through such a nozzle is always sonic at the throat (in all except trivially low pressure systems where it can be subsonic - but these are not usually encountered in practice.
The following text assumes fixed engine and nozzle geometery.
In practice gas flow paths often use "variable geometery" designs to allow optimisation across a range of flow regimes. See "Varible Geometery systems" at the end for a discussion of this.
In jet engines, whether flow is sonic or supersonic at the exhaust depends on the design which in turn tends to depend on the application. "Pure jet" engines which use a combustion driven compressor to compress input air and which develop their thrust from the jet exhaust will usually have supersonic exhausts. Ongoing development has led to a range of "jet" engine types with somewhat differing capabilities - turbojet ("pure" jet), turbofan (jet driven internal "fan" produces air which partially bypasses jet proper), turboprop (jet drives external propeller),propfan (turboprop on steroids optimised for close to Mach 1 cruise) and some fellow travelers such as turboshaft - like a turboprop but with shaft output - useful if you want to power eg a helicopter.
In a turbo-fan engine the amount of air which bypasses the jet engine proper is governed by the "bypass ratio". High bypass engines send most air past the jet proper to be combined with the jet exhaust and form the actual engine exhaust. Pure jet or some "low bypass ratio" turbo fan engines may have supersonic exhausts while "high bypass ratio" turbofan are always subsonic. Modern long distance aircraft (especially airliners) which aim for maximum fuel economy tend to have high bypass ratios. As Mach diamonds are only associated with trans-sonic operation you will not see Mach diamonds from eg a 747.
So, low bypass fanjets may have supersonic exhausts for part of their operation. A turbojet may be sub or super sonic and afterburner will almost always (but not necessarily in theory) produce supersonic outlet flow.
In systems which do have supersonic exit exhaust velocities, as the flow changes from sonic at the nozzle throat to supersonic in the expansion system the aim is to make the exit pressure exactly match ambient. "Exactly" never exactly happens in practice. Where the mismatch occurs there will be a shockwave - an "impedance mismatch in another perspective - and the visible evidence of this are the Mach Diamonds.
As both exhaust pressure and ambient pressure change with conditions there will essentially always be some degree of such shock waves present in "qualifying" systems, but more so when the engine operation departs more significantly from the ideal. Smaller versions may not be obvious without careful examination. As the overall system is usually optimised for "normal" conditions, afterburner operation is more likely to cause a major pressure mismatch as it deviates from normal use.
An exception would occur if the designers decided they wanted absolutely maximum performance from afterburner under given conditions (so that eg an interceptor could achieve absolute maximum velocity when needed) - in which case the Mach diamonds could be minimised on afterburner and would be more pronounced in normal operation.
See this page for some good photos and the diagrams below -
Below: creation of Mach Diamonds from under-expanded flow.
Below: - creation of Mach Diamonds from over-expanded flow.
Good explanation with pictures here - Wikipedia - Shock Diamond
Numerous relevant images - each linked to a related web page.
Variable Geometery systems:
Wikipedia Propelling nozzles
A propelling nozzle ... converts the internal energy of a working gas into propulsive force; it ... forms a jet, that separates a gas turbine, or gas generator, from a jet engine.
Propelling nozzles may have a fixed geometry, or ... variable geometery to give different exit areas to control the operation of the engine when equipped with an afterburner or a reheat system.
When afterburning engines are equipped with a convergent-divergent nozzle the throat area is variable.
Nozzles for supersonic flight speeds, at which high nozzle pressure ratios are generated, also have variable area divergent sections.
Turbofan engines may have an additional and separate propelling nozzle which further accelerates the bypass air.
Propelling nozzles also act as downstream restrictors, the consequences of which constitute an important aspect of engine design.
Characteristics of flow and thrust variations in a jet engine with a variable area nozzle
Paywalled, but freely accessible abstract is useful.
Automotive - but relevant Variable-geometry turbocharger (and interesting :-) ).
Useful Google search on variable geometery jet engine which provides a wide range of pages discussing these features.
AND an even more useful image search using the same terms - each image links to a related page.
Wikipedia - Jet Engine excellent.
He178 0- the very first Jet aircraft
NASA visual Turbojet simulation