Odors don't just float around in the air, they rise up from a surface where there's usually some kind of unpleasant residue (smoke, urine, etc). Getting a carpet cleaning will go a long way towards removing the smells, though an antimicrobial treatment may also be necessary for odors that are thoroughly ingrained.