Pets do level up . As they kill enemies, they gain XP. A pet that starts as a weak goat can eventually become a tanky killing machine if they survive long enough. They gain stat increases and sometimes skill points just like the player.
While pets start friendly and are generally immune to hostile status effects like "love injectors," they are not invincible. Pets - Official Caves of Qud Wiki caves of qud pet
Here is a detailed look at the pet system in Caves of Qud. Pets do level up