The US economy's second-quarter GDP growth was primarily driven by strong consumer spending and increased investment.