It is contraband, the needles are, but they usually use sowing needles that are smuggled in. Your question should really be why is there any contraband, but tbh drugs are extremely prevalent in every prison so imagine how easy a sowing needle would be to smuggle in.