The NHTSA's page about heat stroke in cars seems to imply that if you see a child left in a locked car on a hot day, you should break into the car to get the child out. "If you see a child alone in a locked car, get them out immediately and call 911." The only way to "get them out" of a "locked car" would be to break in. Is this legal?
Oregon allows it, see ORS 30.813. One who
enters a motor vehicle, by force or otherwise, to remove a child or domestic animal left unattended in the motor vehicle is not subject to criminal or civil liability
You have to verify that the car is locked, you have to have a good faith and reasonable belief that breaking in is necessary because of imminent danger of suffering harm, you must notify the police and you must remain with the child / animal until police arrive.
In germany you might be obligated to!
It might appear odd, but in Germany, you are obligated to help if you are able to and don't endanger yourself (§ 323c StGB).
Technically calling 112 is enough to follow this law, but in some circumstances, one might need to do more, so let's assume the person is and wants to help this little more or just is instructed to do more.
If a person is locked into a car and clearly or very likely in danger of life and limb (because it is not apparent if they are sleeping or passed out and not reacting to knocking to the window), any action to rescue the person that is reasonable is allowable and, as long as this reasonableness is kept, things can be taken, destroyed or used to rescue the person - and then returned if possible.
For example, the helper tries to communicate with the person in the car and they don't respond to even banging on the window and shaking the car, so appear very much incapacitated. Now they are allowed to go into the neighboring store, take a tablecloth and hammer from the offered goods and go to the car in the lot whithout paying as the two items are required to effectively assist. This is done to cover the driver-side window with the cloth and then smacking it with the hammer, so he is protected from glass flying. Now he has (somewhat safe) access to the car and can unlock the door safely for him. With the unlocked door, the helper is able to get out the (now clearly) incapacitated person on the other side. How can that be?
Under German law a helper can't be prosecuted for theft of the hammer, destruction of the tablecloth, or damaging the car just to help the person inside. That is covered under "Rechtfertigender Notstand" and "Entschuldigender Notstand" ('Excusing Emergency' - § 34 StGB & § 35 StGB), which makes reasonable measures to protect a life legal, even if they are to the detriment of the owner of the used item, such as damaging someone's car to get to them, or damaging/destroying goods of a third party (the store).
The hammer or cloth of course does not become property of the helper - they have to be returned to their proper owner.
In almost all criminal laws you have something called Necessity (google "Necessity in criminal law"), which allows you to do something that will otherwise be considered a crime under condition that you prevented greater damage than committed by your action. For example, disabling a person who is trying to commit robbery or murder or breaking the window to save someones life.
There is a simple, general answer for situations, when someone is in danger and you don't know what's the right thing to do - call 911. In whatever jurisdiction you find yourself in, you cannot be prosecuted for following operator's instructions (well, as long as it's reasonable to assume they are legal). In the situation you describe, you will most likely be instructed to break into the car and you can do it with peace of knowing you won't get in any legal trouble once angry car-owner returns and tries to sue you.
There’s legal and there’s arrest and prosecution, and finally conviction. That’s four somewhat related things, not one thing.
It’s may be legal under various Good Samaritan laws, but a jurisdiction may not have one that applies. Even if illegal, it probably won’t get you arrested as long as the child is in actual distress. If arrested, you probably won’t be prosecuted as long as you cooperated fully with the cops (no verbal or physical resistance, no talks of law suits). If prosecuted there’s at least a fair chance of acquittal.
Here’s a link to a Greensboro NC police statement: https://www.greensboro-nc.gov/Home/ShowDocument?id=20579. It says to remain with the vehicle until authorities arrive, a link in the document takes you to a non-governmental website that says NC has a law allowing EMERGENCY personnel to break into a vehicle if they determine a child or pet is at risk. So, it seems at least in NC you could be prosecuted.
The thing to remember with any of these types of question is your real risk isn’t the law demanding you be punished for something, in every jurisdiction there’s prosecutors discretion. The real risk is from upsetting someone and their reacting badly. Most likely is the parent walks out just as you are breaking the windows and the child is fine. They now have a broken window which they may take physical or financial exception. Second is cops, and a cop having a bad day is able to escalate just about anything into a legally and physically dangerous situation. Prosecutors generally work hand in hand with the cops, which means that they are likely to at least go through the motions if you are arrested. But, there’s no particular reason to expect the cops that arrive will be having a bad day and if they are, they are just as likely to take it out on the parent as on you.
So, not risk free, but not unduly risky either. Do what you feel is best but be prepared for others not to see it that way and know you may need to de-escalate the situation.