The oil and gas giant said its earnings, which exceeded analysts’ expectations, were bolstered by strong energy trading.