Formation of scalar hair on Gauss-Bonnet solitons and black holes