Nothing lasts forever.
Here is my limited knowledge classical explanation of what probably happened to your crank:
A crack started somewhere in the upper left hand corner of the broken cross-section in the 2nd picture. This crack was present for a long time. It grew and grew over a period of weeks. You can tell because that area is discolored from oxidation and microscopic crud as the crack moved slightly and admitted the outside atmosphere.
One day, at the worst possible time, the crack reached some critical length and broke apart entirely in one instant.
What can you do to avoid this?
Nothing. It is the failure mode of aluminum. The only thing you can do is to inspect your cranks regularly (once a month or so). These cracks grow slowly at first, so you have a chance to catch them if you keep everything clean and look closely. Also, be sure to track down the cause of any squeaks and creaks on your bike-- it could be a crack!