What Was the WannaCry Ransomware Attack?

What exactly happened during the WannaCry ransomware attack? How did it spread and how can we protect ourselves now?