Spent four years in Japan. Got stopped on a regular basis by cops in Tokyo to be inspected for drugs and weapons. Even twice within the span of a kilometer once. Anecdotal, but there you go.
I've been here for thirteen years and have never had trouble with cops. Not once been stopped apropos of nothing and asked for ID, inspected for whatever, etc. If anything, I've been in a few situations where the cops should have given me a harder time than they did, but for whatever reason did not. I'm a white male.
Thing is, I know plenty of foreigners who have a similar experience to your own, so I know you're not wrong. I don't know what I do differently, but Japanese cops do not bother me at all.
I was almost always left alone. I knew a guy who was bugged all the time. The difference between us was that I was quiet on the subway, dressed in a subdued fashion. Basically I was a square. He was not. Japanese cops profile people. I _think_ what it boiled down to was, I didn't look like the sort of person who might be carrying marijuana on their person, another difference between my friend and I :-) This could be extremely outdated information though, that was over two decades ago (thinking about moving back, if a no-longer-young person can somehow find work.)
Could be, but fwiw for a little over two of those years I had a full beard, long hair, looking pretty rough, etc etc. And, as I mentioned, even times when the cops could and probably should have given me a hard time, they did not.
wrt moving back, I will be leaving next year due to the job market here, so there's a data point for you. It's not impossible to find work, but if you're in tech and coming from the US be prepared for a bit of a shock.