Magic can cause creatures and characters to change their shapes -- sometimes against their will, but usually to gain an advantage. Polymorphed creatures retain their own minds but have new physical forms.
The polymorph spell (see page 263 of the Player's Handbook) defines the general polymorph effect.
Since creatures do not change types, a slaying or bane weapon designed to kill or harm creatures of a specific type affects those creatures even if they are polymorphed. Likewise, a creature polymorphed into the form of a creature of a different type is not subject to slaying and bane effects directed at that type of creature.
A ranger's favored enemy bonus is based on knowing what the foe is, so if a creature that is a ranger's favored enemy polymorphs into another form, the ranger is denied his bonus.
A dwarf's bonus for fighting giants is based on shape and size, so he does not gain a bonus against a giant polymorphed into something else, but does gain the bonus against any creature polymorphed into a giant.