The primary purpose of a uniform is within the word itself. "Uniform" means the same or unchanging. Most of the time, group or organisation members wear the same uniform. Schoolchildren and office workers are great examples of this.
However, not all uniforms are created equal.
Some uniforms still differ between the middle and high school, just as office workers wear simple workwear, but executives wear suits. This is status-based differentiation.
Sometimes, the difference in uniforms is a necessity. For example, construction workers wear bright clothing (high-visibility gear) to ensure safety and awareness in their workspace. Meanwhile, metalworkers might wear special gloves that protect them from high temperatures.
In many industries, uniforms are also used to convey a worker's speciality. For example, the nursing staff usually wears a blue vest and pants in a hospital setting. But the doctors can often be seen wearing white coats. They are both medical workers, but their uniforms are different.
They have different jobs, different qualifications, and different levels of expertise. The uniforms are used to identify them instantly, avoiding confusion and miscommunication.
Another example is the military. Each rank has a slightly different uniform. This makes it easier to maintain order and the chain of command. Beyond this, the air force wears different uniforms from the navy, the infantry, and so on. Rank and speciality both apply here. Military uniforms not only provide protection and camouflage but also distinguish allies from enemies and peers from superiors.
Having different uniforms defeats the purpose of a uniform, which is to make all group members look the same. But this is not the case. Despite deviations within a uniform, they often still have the same theme and vast similarities. They still separate an organisation's members from outsiders while allowing contrast within the organisation.
Hence, uniforms can be used both to maintain unity and to differentiate.