Here's an article and a few reddit threads on the subject of creatures with class levels:
https://dumpstatadventures.com/the-gm-is-always-right/dont-give-your-monsters-class-levelshttps://www.reddit.com/r/DnD/comments/a44otf/5e_should_i_build_enemy_npcs_like_pcs/https://www.reddit.com/r/DMAcademy/comments/mf1muh/enemies_with_class_levels/TL:DR
You generally should not build enemies like you would PCs because doing so would make them dramatically stronger than they're intended to be. Enemies are designed to last a while and deal moderate damage to the entire party whereas players have less HP but can deal more damage through class features and abilities. Classes were never designed with PvP in mind, so making players fight enemies designed with class levels would be brutally difficult and imbalanced.