A uniform isn't just tradition for tradition's sake. In the Gi, the jacket and pants genuinely change the technique, learning to fight through grips and control fabric is a real, transferable skill, especially for self defence, where an attacker's clothing is exactly what you might need to control.
A proper rashguard and shorts for No Gi matter too, loose t shirts and boardshorts get grabbed, twisted, and generally get in the way of both people training safely.
There's also something simpler at play. Everyone in the same uniform, working through the same belt system, training toward the same standard, that's part of what makes the mats feel like a team rather than a room of strangers.