FactSet and Gartner are among the S&P 500’s worst performers this year — but some on Wall Street see resilient and sticky businesses that can adapt to AI.