Animal companions do not earn xp, nor do they get a share of party xp.
Familiars already gain powers as the mage levels. Some special familiars may have the ability to gain levels. Such familiars are not normal animals to start with. Note that if they do so, they are considered an NPC and thus reduce the overall party xp available.
Awakened animal companions count as full NPCs, and will gain levels. The levels are typically in their race, warrior or fighter. They may be eligible for special prestige classes. See Masters of the Wild for details.