These tiny muscles are attached to each hair follicle. When they contract (usually in response to cold, fear, or excitement), they pull the hair follicle upright, creating a small bump on the skin surface. This also causes the hair to stand on end, which is why it's called "piloerection".