Two unions representing railroad workers have reached tentative agreement with major U.S. railroads, averting the immediate threat of a national labor action.