A man armed with a knife has been arrested outside Buckingham Palace, leaving two police officers injured, Scotland Yard said.