An abandoned building is still private property and someone holds the legal property rights to that property even though the property is abandoned.
Some abandoned buildings may have alarms that alert the police and others may have private security guards patrolling the property.
If you are on the property and roaming about the abandoned property and you get caught trespassing in an abandoned building then you will likely be warned first to stay off the property by the security guard or police.
If you return to the private property and abandoned building then you can be arrested for trespassing.
If you get arrested for trespassing you can bail out of jail but it will probably cost you $500.00 or more to get bailed out of jail.
If you get caught trespassing in the abandoned building and they warn you to not come back then head the warning because it's not worth going to jail over.