I understand {Painful Quandary} forces the opponent to lose life if they don't have cards in hand after casting a spell. My question is if they do have a card in hand, should it be read as "When an opponent casts a spell, they lose 5 life. They may instead discard a card to prevent this life loss"?
More or less, yes.
It's not damage that is prevented, it just never happens. But yeah, that's the idea.