I don't know if there is any clear answer to this, brokenwarrior. Generally, I think, SH is a response to anxiety & emotional upset. So the only thing that occurs to me is, even though home is not a safe place for you, your level of anxiety gets higher out in public to the point where your urge to self harm becomes greater. Perhaps, when you're out in public, circumstances are more unpredictable than they are at home? I don't know.
My urges to self harm have always been greatest when I'm at home alone because that's when I would have the opportunity to SH. That might be another possibility, I suppose. Is it possible you first began to SH in response to some thing(s) that occurred out in public and, as a result, your urge to SH became tied to being out in public?
Perhaps some other PC members will have some other ideas. My best wishes to you.