In WW2, were self-sealing fuel tanks really cost-beneficial?
Your description of a self-sealing fuel tank remaining on fire when lit is the exact situation of the sealing mechanism failing. As soon as the tank is punctured, regardless of a fire or not, the rubber in the middle layer will react with the fuel and swell until the hole is reasonably obstructed. This both extinguishes the fire and seals the leak. Consider a case study: in the Pacific theater, Japanese fighter designs did without self sealing tanks for the cost and weight saving benefits. American naval designs such as the Hellcat however, had every possible damage-control system of the day installed everywhere possible to make the planes as rugged as they could. In the end, Japan mainly lost control of their own airspace due to the fact that they simply ran out of materials to build new planes from. The rate at which they lost planes was incredibly high due to both the small .50 caliber rounds' ability to set the unprotected tanks on fire, and the poor training of Japanese pilots towards the end of the war. If you look at statistics, per battle the IJAAF and the IJN lost more planes per squadron and battle group than any other country's air service in the war. In fact, many of the IJAAF's main fighters including the Mistubishi A6M Zero and the Kawasaki Ki-61 Hien were infamous among pilots of both sides of their ability to catch on fire from what should have been inconsequential hits and particularly their inability to stop burning. Another point of interest is the design of the self sealing fuel tank:

This all goes to prove strongly that NO, self sealing fuel tanks are a definite must in combat airplanes, and a very important safety feature in other aircraft types. I'm confused however as to why your question switches from bullets (incendiary?) to flak as anti-aircraft guns such as the Flakvierling88 were not meant to ignite fuel tanks, they were supposed to destroy the whole plane, fuel tanks and all. If you want some more numerical data backing up my position, Wikipedia references many sites that give a bit more data on why self sealing tanks are a must for fighter planes. The Defense Systems Information Analysis Center also provides some interesting information on the design and how they weren't all too much of a cost/weight penalty later in the war. Hope this answers most of what you're asking.
In addition, there is a specific part of the article of my second link I would like to draw attention to:

This simple composition and design, which are inexpensive, lightweight, and easily produced in large volumes, confronts the deceptively complex ballistic dynamics of a bullet perforating a fuel tank.  When a normally oriented bullet pierces a fuel tank, it leaves a small residual hole less than the diameter of the projectile.  But this small hole is just the beginning of the challenge.  The bullet, travelling at 3,000 ft/s, begins to unload its tremendous kinetic energy on the fuel inside.  This unloading generates a high-velocity wave of pressure in the fuel that is reflected back on the wall milliseconds after the bullet tears through.  This pressure wave, known as hydrodynamic ram, blasts a jet of fuel back through the entrance wound.  The bullet, still moving at a high velocity, and now followed by the same pressure wave, begins to tumble as it travels through the fuel.  When it reaches the back wall of the tank, the bullet erupts sideways through the material and leaves an elongated gash that is often torn further by the trailing wake of hydrodynamic ram.
Initial fuel tank prototypes tested by Navy engineers were discouraging failures.  Engineers had not anticipated the challenging dynamics, and often the entire back walls of prototype tanks were blown out by the hydrodynamic pressure wave.  However, these early development tests shed some light on the mechanisms that brought down so many pilots and aircraft during the World War I.  The Navy and rubber company engineers persisted and established remarkably effective design features and manufacturing processes that ultimately saved untold lives not just in World War II but in each of the armed conflicts since then.

This statement strongly backs up the cost/weight penalty not being an issue position, if this clears anything up.