In vanilla, sadly I don't think there is a way to stop the clothes from all auto changing. You'll just have to redesign all the clothes categories again once you have changed the sims gender in CAS.
Same with the CAS gender settings, again, you'll just have to click on the three dots under the gender settings to use the Custom Gender Settings to reset the physical frame, clothing preference etc as you want after you've changed their CAS gender settings from female>male or male>female
Not sure if there are any mods that would change how this works, maybe ask on modthesims?