Many factors.
Intrinsic intelligence/ability - this could mean it's possible to compensate for everything that would ordinarily result in poor academic achievement or attendance, give an ability to learn things on the hoof and lead to their realising very early that the life they're living isn't one they want to continue as a adult.
Exposure to other ideas - whether through books, TV, films, it doesn't matter. Whilst the inadequate parents think that the child is out of their hair watching Spiderman cartoons and the like, they're actually learning about the Hero's Journey, that actions have consequences, doing what is right, that the correct way to behave is to protect the vulnerable, that with great power comes great responsibility, that even the strongest person can falter and the key is to keep on trying. They're also seeing that other people have clean, safe homes, loving parents, that they aren't going hungry or are hit regularly, people have jobs, that scientists and archaeologists are cool...
An element of trauma response/neurodiversity can help. The same patterns that create object impermanence (if I can't see it, I don't think about it) can mean that they can create a separation from the abuse and now - that was then, it wasn't my fault, it happened and it's not happening now. The environment is rapidly changing? Yeah, I would spend my days being told black was white and then how stupid I was to think that when it's obvious black is grey and they never said anything of the sort, I'm just stupid and make things up - having to stop doing task #1 in that way to respond to task #2 and now back to task #1 but it's different now because the boss has changed their mind - mehhhhh, whatever.
There's desensitisation. If the original experience of displeasing somebody was that you got a punch to the side of the head, you're not as likely to be bothered by somebody ranting at you down the phone or somebody kicking off that there's no A4 in the photocopier - it's over there (which also drops in a subtle 'Do it yourself and stop having a go at me when it's not my job or problem' assertiveness without actually having to say it and causing workplace issues). Am I going to panic and completely lose my shit, calling somebody stupid for dropping and smashing a mug? Nope, it's an accident, the sound might make me jump and remember when i dropped something, but that was an accident too - or it'll be 'it's not as if it was being thrown at me, hope she isn't hurt, let's get this cleaned up 'are you OK?' '.
An acute sense of body language. If you're trained from birth to recognise those tiny signals in front of everybody else that you're going to pay for this once you're indoors, you notice people's unconscious signs which makes you very good at handling the more challenging situations - and knowing not to trust the person whose smile doesn't go past their nose at all. Also means that you have a better chance of finding some genuinely lovely people because they're broadcasting to all and sundry through their body language and a genuine smile.
And there is fundamental personality. Sheer bloodymindedness really helps. All those things you got criticised, hit, punished, mocked for? Chances are that they're exactly what you need to get on in life - because that's why they were targeted in the first place; they were a threat to the abuser.
Luck of the draw, really, whether you have those things to help or not. And if there is actually proper help/caring/interest from people with both the will and the authority to actually make a difference on top, that would be nice, too. That also depends upon whether the abuser is more skilled at abusing or not, as if they can manage to make the child as hard to like/engage with as possible, it's less likely they'll ever be in a position to disclose anything in the first place.