The AI boom has reshaped stock markets, but a June selloff exposed the risks of lofty valuations and growing concentration.