Some stocks’ price-to-earnings valuations declined even as they outpaced the S&P 500’s big gain.