The foam cannon shoots thicker foam than the gun. The thicker the foam, the more it is able to hold on to the car’s surface and remove dirt efficiently. Remember, thicker foam is able to lubricate dirt more effectively, and thus it is able to remove it safely without creating swirl marks.
Apart from that, the foam cannon comes with extra fittings for adjusting/optimizing the cleaning process. Because of these and other reasons, the foam cannon is much better than the foam gun.