Salam,
This verse 74:31 is likely a later interpolation in Qur'an, that was not part of the original Qur'an.
The verse in question is:
وَمَا جَعَلْنَا أَصْحَابَ النَّارِ إِلَّا مَلَائِكَةً ۙ وَمَا جَعَلْنَا عِدَّتَهُمْ إِلَّا فِتْنَةً لِلَّذِينَ كَفَرُوا لِيَسْتَيْقِنَ الَّذِينَ أُوتُوا الْكِتَابَ وَيَزْدَادَ الَّذِينَ آمَنُوا إِيمَانًا ۙ وَلَا يَرْتَابَ الَّذِينَ أُوتُوا الْكِتَابَ وَالْمُؤْمِنُونَ ۙ وَلِيَقُولَ الَّذِينَ فِي قُلُوبِهِمْ مَرَضٌ وَالْكَافِرُونَ مَاذَا أَرَادَ اللَّهُ بِهَٰذَا مَثَلًا ۚ كَذَٰلِكَ يُضِلُّ اللَّهُ مَنْ يَشَاءُ وَيَهْدِي مَنْ يَشَاءُ ۚ وَمَا يَعْلَمُ جُنُودَ رَبِّكَ إِلَّا هُوَ ۚ وَمَا هِيَ إِلَّا ذِكْرَىٰ لِلْبَشَرِ
The litigious expression is أَصْحَابَ النَّارِ / ashab an-nar. In this verse, it is understood as the wardens of the Fire, and those are Angels.
But the same expression is used in verse 2:39:
وَالَّذِينَ كَفَرُوا وَكَذَّبُوا بِآيَاتِنَا أُولَٰئِكَ أَصْحَابُ النَّارِ ۖ هُمْ فِيهَا خَالِدُونَ
In this verse, the أَصْحَابَ النَّارِ / ashab an-nar are the people who deny the signs of Allah.
Clearly, it is not possible for the same person, be it Allah, to have used the same expression with such opposite meanings.
It sounds like verse 74:31 was initially more a commentary of Surah 74 that has later been incorporated as a verse when later scribes started to make a written copy.
This happens fairly frequently in history.