Elon Musk's Tesla shares fell 7% despite reporting better-than-expected second-quarter deliveries, as investors focused on profits, AI investments and long-term growth prospects.