Punishment and liability
By law, everyone is obliged to provide necessary care to animals in need. The one who doesn't is punishable. The person who left the dog in the car is also punishable. When it comes to a matter of life or death of a dog in a car, breaking a car window can be regarded as a matter of care. You act in the interest of the owner of the dog and car. After all, your actions prevent more 'damage' to an owner's property, namely the dog. Any additional damage caused by this action, such as the window, will then be borne by the owner.