Mechanical systems fail too. Cables can snap, gears can shear off, pedals can bend. As long as you require an appropriate level of redundancy, there's no reason an all-electronic plane should be any less safe.
In both of these cases, rapid decompression from a failure of the cargo door caused parts of the floor to collapse and sever or restrict the mechanical cables leading to the aft control surfaces of the plane. Although the American Airlines pilots were able to land the plane safely (they still had some control), the Turkish Airlines pilots were not so lucky.
Furthermore, even mechanical systems are assisted by hydraulics. Hydraulic systems can fail, usually through draining, leaving the flight uncontrollable. So to add to the comments by both lmm and leoedin, safety has no bearing on whether the aircraft is mechanically controlled or electronically. There are also deployable ram air turbines[1] that can provide a small amount of emergency backup power in the event of a total failure of all engines: