WASHINGTON—Economic growth was stronger during the second quarter than earlier estimated, although growth in a key measure of U.S. corporate profits moderated from the first quarter.

Gross domestic product—the value of all goods and services produced across the economy—rose at a 4.2% annual rate in the second quarter, adjusted for seasonality and inflation, the Commerce Department said Wednesday.

The...