The shirts had hidden zippers along the seams leading up to the neck. If you watch carefully, you can see them sometimes. This is especially true for seasons 1 and 2, filmed before they switched to a new fabric. The original velour (made of cotton, I guess) shrank every time it was cleaned, and the uniforms were cleaned every night. They had to be recut and refitted constantly. (Watch how the bottom of Kirk’s tunic rises and falls according to the size of his belly.)
The situation in TNG was no better. The original Spandex uniforms made movement difficult (the reason for the Ryker sit-down maneuver), and the synthetic fabric retained BO like it was going out of style.