When the ignition switch is turned on, the warning light is supplied from the battery and hence becomes illuminated. When you start the engine, the alternator voltage produced is applied to the light also on the other side of it, and largely balances out the battery voltage and as there is then little voltage across the light,(maybe only a volt or so difference) it goes out.
If your battery is bad, the car probably wouldn't start in the first place, so we look towards the alternator.
A loose alternator belt is a strong possibility as immediately after starting, the alternator has to work hard to restore charge to the battery so a lot more force is applied to the belt which can slip if not tight enough. Another possibility is if your tick over speed is set very low, the alternator may not quite manage to produce enough voltage at such low revs.
Other possibilities of course include a faulty alternator or poor/ loose connections.