The world’s best-performing stock is turning into a cautionary tale for investors chasing outsized returns from the artificial-intelligence boom.