Why was it decided that both sides would wear uniforms?

They did not feel dignified out of uniform.
Neither side knew who their own troops were.
They had trouble with spies.
Young boys were sneaking onto the battlefield to fight.