The caste system, or the Varna Vyavastha, is a function of human society and does not always apply to non-human beings.
It might help to understand that there are classes of Hindu gods. Here is a brief video I made some time ago to explain the many worlds in which gods and celestial beings of Hindu mythology live.
There are the high gods like the trinity of Brahma (the creator), Vishnu (the preserver), and Shiva (the destroyer). These are cosmic gods who are said to reside on a level that even lower gods hardly ever access. These gods (the trinity) have no caste.
Then there are the devas, the elemental gods of Swargaloka. These are Indra (rain and storms and thunderbolt etc), Agni (fires), Vayu (wind). These gods also don’t have any caste as they are not part of human society.
On the human level, there are beings and persons who have been worshipped as gods. These are avatars and sages.
- Rama was a Kshatriya who was banished from a royal palace and lived in the forest as a hermit with his wife and brother.
- Krishna was a Yadava who moved on from being a cow-herder and became a king-slayer as well as a king-maker.
- Parashurama was a Brahmin who took up weapons for revenge and fought Kshatriyas.
- Valmiki (the composer of the Ramayana) was a forest bandit who is worshipped as a sage.
- Ved Vyasa (the composer of the Mahabharata), was the son of a sage and a fisherwoman who later became a queen.
- The five Pandava princes — the sons of Kshatriya king Pandu — where not actually his biological sons.
- Hanuman the vanara god did not have a caste as he was not part of human society.
Examples such as this abound and it is really a mixed bag at the end of the day. Here is a video which goes into how almost all of the Hindu epic narrative is about how castes relate with each other.