The I'm sorry (that someone died) is easy to explain as it's obviously connected to the word sorrow. The hardest is "sorry?" (I didn't understand or hear you)
"Sorry" is most commonly translated as "xin lỗi" which literally means something like "request forgiveness". It's connected exclusively to the notion of fault, not sadness. The real issue is that sorry <-> xin lỗi is a ubiquitous but poor translation, because the meaning of xin lỗi is much more specific than sorry.