Tesla Inc. late Wednesday reported second-quarter earnings and sales that topped Wall Street’s expectations and kept its 2023 goal of making about 1.8 million vehicles this year, but the stock headed lower as results didn’t quite match expectations of a blowout quarter.