It's a personality type, I think. I am not sure there is a secret to not giving a shit, some people just don't and others do.
For me, even though I philosophically disagree with the concept of land ownership, I also understand that living in a society where land owners have the full force of the law behind them (especially in countries with no "right to roam" and barbaric "stand your ground" laws, e.g. the US), I would rather not tempt fate.
That said, I feel differently about residential areas vs commercial areas. I don't trust personal land owners to be respectful of visitors, because too many are on a power trip who think because they signed a piece of paper they are now lords of that domain with no further duty to society. I trust corporate land owners a lot more, because they have a clear motivation to keep trespassers out using a cold economic calculation. Their level of security should be aligned with their (or their insurance company's) valuation of the assets on the property, and the risk that a trespasser might turn out to also be a vandal or a thief. If it is a property with not much worth vandalizing or stealing, or if it is in a location with a low rate of vandalism and theft in the first place, the security should be less, the company should care less about a visitor who's gone before the first workers get in (at which point you have to deal with irrational individuals again). Industrial properties are similar to commercial locations, with the added point that there could be dangerous machinery that can injure an unexpected visitor, so the company might want to avoid trespassers primarily for liability reasons (e.g the railroad case).
Public property is best, imo. There is no good reason to block the public from sleeping on land that ostensibly is reserved for their use, especially in urban areas where there is no wildlife protection that might conflict with the use by humans. In some locations cops might try to move you along for whatever stupid policy or bylaw, so it's still not going to be as relaxing of a sleep as a place that explicitly allows the public to rest, but morally (and perhaps legally) you have a stronger leg to stand on. That helps me sleep better.
Does this help you to decide where to sleep? Well, a regular rough sleeper is going to say it's all the same because they don't have the emotion in the first place, so that's not helpful if you are feeling some amount of guilt or stress over sleeping somewhere illegally. But if you are having that feeling, and you really cannot find anywhere else to sleep that night, then I think the best way to go is first seek out a corner of public property where you are not likely to freak out another member of the public, then seek out a corporate location in a low crime area with no valuable products or art on-site, then consider other corporate locations, possibly also looking at industrial locations if you know you won't disturb the work schedule, and only in the last resort consider individually owned properties. I say this never having slept rough on an individually owned property out of fear for psychopathic owners, because I have met enough of them even when I was an invited guest and have no desire to wake up to an idiot pointing a gun in my face.
Perhaps I am lucky that a security guard or cop never pointed a gun in my face. I guess that speaks to how much I avoid sleeping rough in the first place, especially in countries with a gun culture like the US. I am not an expert at it because I am not interested in dealing with the fallout. All I can say is that individuals who own land are not to be trusted, imo, not in the context of rough sleeping or anything else involving "their" property. They will never do what is best for the public while they own property that they think should give them extra rights. Corporations and governments have policies that may be immoral but are at least predictable. I would rather deal with the faceless bureaucracy.