Reliable research has shown that pets such as dogs and cats have the same Rapid Eye Movement that humans do which is associated with dreaming.
And in addition, during REM sleep dogs often make movements with their legs and utter some guttural sounds similar to barking etc., so it’s reasonable to assume they are dreaming.
Research has even shown equivalent signs of dreaming in pet birds.
For humans, dreams are the broad equivalent to those processes which keep our physical bodies in an equilibrium.
For example, automatic adjustments are continually made to keep a person’s temperature, blood sugar level, water content etc. etc. at appropriate levels.
In an equivalent way, dreams try to maintain an overall psychological balance which will allow for the gradual all-round self-development of the dreamer where no one generally narrow viewpoint or attitude etc. is tending to restrict a gradual movement toward all-round understanding and maturity.
While this too is a kind of “automatic process”, a competent and ongoing analysis of a person’s dreams can help to speed things up .
Since we can’t really get a description, for example, of what our pets are dreaming and “discuss” it with them, there are various theories about what purpose dreaming serves in animals.
These include the idea that images in dreams are kind of practice runs for hunting prey etc. which improves the chance of catching it.
Some research shows that the ongoing presence of apparently “bad dreams”, as it were, could possibly be reflecting a pet’s worries over a bad relationship between a couple on whom it relies for its care.
Anyway, I hope these ideas have helped to answer your question.