The economy grew far less than expected as inventories fell for the first time since 2011, but a surge in spending pointed to underlying strength.