It stands to reason that there must be an area on the ship which is dedicated towards the production of clothing. Consider that the Enterprise under Kirk was assigned a 5-year mission during which it could expect only infrequent resupply or contact with dedicated Federation outposts.
Uniforms, even ones made of tough, resilient fabric, wear out. Over the course of five years, it isn't unexpected that crewmen would need new uniforms - the ability to produce new clothing from shipboard resources would practically be a necessity.
When you further consider that the crew was expected to encounter 'new life and new civilizations' and interact with at least some of them discretely, a costuming section would be expected. Most likely, there is one or more people in the quartermaster's department who is responsible for the creation of new uniforms and local costumes as needed. It is well within the scope of 22nd century technology to remotely scan population centers for typical styles of clothing, the quartermaster would (by necessity) have the sizes for the crew members, and rapid fabric shaping is hardly a surprising capability for a culture as advanced as the Federation to have.
Thus, the Enterprise had a dedicated Wardrobe section. Presumably, the people who worked there also did general quartermaster duties as well (in short: they handled the logistics of moving materiel).