With the first novel it's easy to see why a writer would choose to kill off a character - it's an unexpected twist. The drawback is that, because the death comes close to the end, after the character is killed off, the book loses impetus and fades out a bit. This is because the unexpected death doesn't tie in with any particular theme - except possibly the randomness of life (and death). The writer in me suspected that the author used the death as a convenient plot 'Get Out of Jail Free' card, and the reader in me resented that.
However, I think bumping off a main character unexpectedly can work - if you get the timing right. Do it early enough in the book, and the reader realises that this book could go anywhere - Absolute Power by David Baldacci is a great, page turning example of this. (And in Executive Action, a daft film where Steven Seagal - known super hero - dies right at the beginning, leaving saving the universe down to Kurt Russell.)
With the second novel, I'm assuming the writer wanted to add tension to the story - yes, this character is going to die young, but when? how? The drawback for me was that, I disengaged with the character at that point. Put crudely, if she was going to snuff it, why spend much of my attention on her? And in plot terms, knowing beforehand actually reduced the mystery of the plot as it explained why and how two apparently loose ends were going to be tied up.
But it can be done well. At the very beginning of The Secret History by Donna Tartt we learn that one of the friends has been murdered by one of the other friends - but we don't know which one. The novel unfolds with this big question throbbing away underneath it: who dunnit? why? At the very, very end we discover the answer.
I've not killed off any of my main characters - so far. But when I teach I'm always talking about change being the engine for moving a story forward. The absolute removal of a character is about as complete a change as you can have and one which can, unless you're careful, stop the story completely. One to be handled with care...
PS If you want to know which novels I am referring to, email me email@example.com and I will Reveal All.