I suppose Harry Potter and just about every children's / YA fantasy (or mystery) series would fill this bill, but big HP and Three Investigators fan though I am, let me offer these for consideration instead:
1. Mark Twain: The Adventure of Tom Sawyer -- Tom and Becky Thatcher in McDougal's Cave (rescued thanks to Tom's tenacious search for an exit), and Tom and Huck Finn up against Injun Joe; inter alia, listening to Joe's and his cohorts' plans at the peril of their own death in case they are discovered, and Tom incurring the same risk by speaking up at Injun Joe's trial (after which Joe escapes through a window).
2. Frances Hodgson Burnett: The Secret Garden -- At the beginning of the book, Mary is sent to England to stay with her uncle to save her from the cholera epidemic that will shortly thereafter kill both of her parents, who have remained in India.
3. Walter Farley: The Black Stallion -- Alec and "The Black" become friends when they help each other to survive on a desert island after being shipwrecked.
Honorable mention:
"M" (screenplay, not book): A chillingly creepy 1930s movie, concerning the hunt for a pedophile serial killer -- starring Peter Lorre (pre-Hollywood) as the pedophile and directed by Fritz Lang.