the 59th Street incident was because of someone doing graffiti on the tracks and got hit by a train. This is why you stay away from the train tracks.
the Dekalb Ave incident was a work train derailment (RD407); AFAIK the switch moved while the train was over it causing the derailment.
here is a photo that was spread on facebook (idk who took it):