The を in these phrases is not the case particle you are used to. Here, it is a conjunctive particle, which is a usage from Classical Japanese that remains in these expressions. Pay attention to what phrases these phrases are similar and the things that make them different.
漢字 Note: The やむ in やむを得ない can be written in 漢字as 止む or 已む.
～ざる is the 連体形 of the classical/old-fashioned negative auxiliary verb ～ず; thus, this pattern attaches to the 未然形. 得ない is the negative form of 得る. Put together, ～ざるを得ない means "there is no other choice but to". As for する and 来る, you must use the せ- and こ- 未然形 respectively because we are using an older ending. So, never say しざる.
Common questions in regards to this pattern include what the subject of the sentence, when it is appropriate to use, and how it differs from the “must phrases”. This phrase has a negative tone, and should not be used in situations where such implications would be inappropriate. The action is something that one does not want to really do. There is also some outside force that is making you have .It is this that separates it from the “must phrases”.
Although this is typically more common in the written language, it is still occasionally used in the spoken language. In this case, it is often followed by things like ～だろう・でしょう, ～（ん）じゃないか, ～と思う, 等.
We have no other choice but to recognize…
There was no other choice but to call off the picnic due to the weather.
If this computer breaks, there is no other choice but to buy a new one.
There's no other choice but to go to the dentist.
There’s no other way but me having to undertake it, no?
When you travel overseas, you have no other choice but to be conscious of the fact that you are an American.
If the student fails an exam, the student has no choice but to take responsibility.
Since this is an order from the company president, I have no choice but to do it.
We have no choice but to examine this problem one more time.