It is unthinkable for a U-boat from the first world war to
run out of power to steer around when patrolling in the
North Sea. How is it possible one century later a cargo ship
equipped with modern technology isn't even equipped with
diesel fuel generator for power back-up?
The consequences for a power failure on a submarine are quite different than a surface ship though.
I believe large ships are required to have backup generators. The questions then are: how often are the backups tested and maintained, how often does the crew do emergency drills and who checks to make sure the procedures are being followed. There's plenty of opportunity for mistakes or plain negligence in all these steps. Even if these things are done properly and regularly (there's likely some lapses), then there's the always the chance of the crew getting startled when the real thing happens and chaos ensues.

