The New York Stock Exchange cancelled trades in six stocks after an electronic trading system run by Knight Capital malfunctioned and revived memories of the “flash crash” of 2010.