Why not? And anyway, they could at least try to do it in semi-privacy - maybe behind a building, or in the bushes, or something. No, it seems almost deliberate to me, or alternatively so zonked out on drugs/malice that they just couldn't give a damn. Either way it's not just a lack of facilities. We've all been in a strange part of the city we don't know well, no toilets anywhere and busting to go. We all somehow found some kind of semi-acceptable solution that didn't involve shitting on someone's fence.
I have no idea why it's different in SF but these things just don't happen elsewhere, so there must be some reason for it.
Frankly, I'd rather walk by the occasional fence than risk going into a public restroom after a homeless person has used it.
Evidently in the past there was a move to provide lots of public restroom facilities in the city, but they were soon condemned and removed. It would take significant resources to offer such facilities and keep them clean and safe.