Why did the soldiers wear uniforms during the civil war?

Soldiers wore uniforms during the civil war so that they would know who was the union and confederate.