Amazon’s soaring cloud business, along with its fast-growing advertising division and a strong showing from third-party seller services, helps offset downturn in online retail.