Bacterial lifestyle alters the evolution of antibiotic resistance