I think your analog video board has gone bad. This is the part that drives the CRT display. There is a part on it called a flyback transformer, and it is a fairly common failure point on these old iMacs as they get older. The iMac does an internal self-test during startup. It is failing this test, and shutting off (probably for safety reasons). Unfortunately, for most people, it is not an economical fix (compare to the value of the iMac).
If it's a tray-loader, you can test to see if this is the likely problem. Take the bottom panel off. You will see an internal cable that looks like a video cable. If you upgraded the RAM before, it is one of the cables you disconnected when you pulled out the internal chassis. Leave the other cable or cables connected; just disconnect the one that looks like a video cable.
Now try to start the iMac. If the problem is on the analog video board, your iMac will now start up normally. You have bypassed using the analog video board, so the startup hardware test does not fail and the iMac starts up. Obviously, you won't see anything on the display, but by the sounds it makes, you should be able to tell that it is starting normally. You can shut down without video by waiting until it gets to desktop (based on time and sound), and then pressing the power button, followed by the Return key.
You can actually use it this way, by getting an adapter for the internal video connector (about $5 on eBay) and attaching a standard VGA cable and VGA display. If you want more info about doing so, please post back.