Cleanliness is... mostly downstream of storefronts and the like picking shit up _all the time_. There are pockets of land that don't end up people's direct responsibility and end up getting very dirty very quickly. Little micro-pockets of trash that pile up (very quickly!). But lots of places you tend to have someone going around and just picking something up.
For like a year there was a guy consistently eating his cup noodles or lunch box near my building, and he would just drop it near the bike parking. But we had somebody come by the building twice a week to deal with trash and the like and he was picking it up (I'd throw it into a garbage bag if I saw it and had one in my hand). Still though, like if I'd go on a midnight walk I'd see it.
Turns out that the way super crowded places can be clean is by cleaning constantly (see also restrooms, which need to be constantly cleaned). "Nothing is broken" also definitely feels downstream of people fixing stuff promptly. Low latency when trying to deal with issues might be key.
And an aside for the public transit... while the transit feels clean, ask most any woman living in Tokyo how they feel about riding public transit. Many might still grade it above other ones but I have heard many nasty experiences that white guys just don't get exposed to at all. Groping, verbal harassment, the works.
EDIT: I mention lots of this to get to a bigger point: good things are possible! There is no magic entirely localized in the Japanese Isles.