The companion does not gain any more hit dice as the ranger levels up.
The number of hit dice of the companion is fixed: the statistics that are different from the basic stat block of the beast are enlisted in the ranger feature description. Hence, if the DM allows to pick a Dimetrodon as a companion, they will have 3 Hit Dice to spend, regardless the ranger's levels and the HPs they have.
If the number of hit dice would have been increased as the ranger gain level, the feature would have pointed it out.
For comparison, see the Drake Companion from the Drakewarden subclass:
Hit Points 5 + five times your ranger level (the drake has a number of Hit Dice [d10s] equal to your ranger level)
The Beast companion is not gaining levels.
You wrote
Every player class gains Hit Dice as they gain levels so shouldn't it be the same for animal companions?
Since the beast companion is not gaining levels, they are not gaining any more hit dice. If the DM decides to modify the subclass such that the companion can have a class and therefore they can level up, then normal progression applies.
There are other ways to restore HPs.
You wrote
Since the class lacks any feature for having your companion regain HP (apart from wasting your precious spell slots in it) [...]
Actually, there are several ways to make the companion restore hit points, you do not need special class features: Cure Wounds from other characters and/or temple, potions of healing and do not forget long restslong rests.
The companion is a "normal" creature (of type beast), not a magical one: they are a creature that can be healed following the common rules.