A freight train has derailed and toppled onto houses alongside the tracks in western Mexico, killing one resident and injuring three others.