The term "backfire" is frequently used incorrectly to describe or refer to flames coming out of the exhaust tip. That is considered an "afterfire", and happens when hot, unburned fuel in the exhaust gasses ignites. Afterfire is common on high performance motors.
Actual backfire occurs in the intake when the air and fuel combusts before the intake valve closes.
An afterfire occurs when enough extra fuel ends up in the exhaust and combusts within it. This emits an audible pop sound, sometimes in rapid succession. It occurs more often in engines that have been tuned for more power, especially in race cars.