难怪 - no wonder - is said after learning the reason, so it always looks backwards. 幸亏 - fortunately - names the thing that averted trouble. 居然 marks disbelief and sits before the verb, like 竟然 in the reaction set.