Children are encouraged to wear their uniforms outside of school specifically so that they DON'T end up hanging out in alleys after 10pm. Students are under a great deal of pressure to act in a way that would not embarass their school or draw undo attention to them. Students in uniforms are encouraged to give up seats on the bus or train to others, they're not allowed to eat or read while walking, be out after dark without a reason or in big groups, etc. Students wearing uniforms are almost always reported to their schools by police and other parties for any "suspicious" activities. Local police know the schools' uniforms and insignia on sight and will often file complaints based only on the uniforms suspects were wearing. Wearing your uniform to cause trouble, smoke, drink or get laid is a really rotten idea: and one of the best ways to get caught. Some students do: but they're exceptions, not the rule. Generally speaking, you will see very few students in uniforms "hanging out" after dark: just a flood of them returning home late from cram school.
I work at a junior high school and the police often arrive unannounced to deliver complaints to the staff about boys in our school's uniforms that have been involved in vandalism or loitering. Girls have been reported anonymously by others in the neighborhood for everything from littering and being noisy in public places to having boyfriends in college. All the kids are reported constantly for failing to wear their bike helmets.
The worst uniform "offense" most students commit is to hike up their skirts the second they're out of the immediate range of school and think they won't be seen by their teachers.
As for why students spend so much time in their uniforms: the school day in Japan runs from about 7am-4pm with club activities in the afternoon and cram school soon afterward. There's no time to change even if they want to. Most students also attend school on Saturdays for extra classes and/or club activities. Their "encouraged" to wear their uniforms on Sundays also... specifically so that they can be "kept an eye on". But on Sundays and Saturday afternoons, most students opt for their "regular clothes"... summer and winter vacations are also remarkably light on uniform presence. They don't usually WANT us to know what they're doing... or make it any easier for us to find out.