The heart has nerve cells which are supposed to fire synchronously. This is what allows the heart to pump effectively. Fibrillation is when nerve cells (or the cardiac cells themselves, which have some "pacemaker" activity) are firing asynchronously, which means blood isn't getting pumped.
The shock causes all of the units to fire at once (which isn't exactly asystole), in the hopes that when electrical activity resumes (after giving a shock, we wait and look at the monitor to see if there is a regular heart beat, we do not start CPR unless there is not), it will do so in an orderly, synchronous manner.
In asystole (flat line), there is no longer any effective electrical activity of the heart. There is basically no disorganized electrical activity to try to reset with a shock.
That is why it makes no sense to shock someone in asystole. On television, people in flatline are shocked into a stable sinus rhythm. That just doesn't happen in real life. Neither does a deep breath and fluttering open of eyelids, as often shown on television when someone arrests and resuscitation is successful.
Asystole @ Medscape.com
Treatment of Asystole @ Medscape.com