Trap Door will lock on to one of the characters with Target, then cast Ninth Dimension on the next turn, instantly killing the targeted character. An easy way to defeat the Trap Doors is to wait for it to cast Target, then have Rosa cast Reflect on the targeted character. When the Trap Door casts Ninth Dimension, it will kill itself instead. This works in all versions of the game.
In addition to the aforementioned strategy, a good way to stop Ninth Dimension is to cast Berserk on the Trap Door. It will use its regular attack, inflicting around 1,000 damage, rather than Ninth Dimension. The Slow debuff will usually prevent the Trap Door from casting Ninth Dimension before it is felled by the party.
Alternatively, one could give Cecil the Draw Attacks Augment (obtained from King Giott after defeating Golbez in the castle's Crystal Room) and the Aegis Shield (if one goes to the Feymarchbefore the Sealed Cavern). Because of Draw Attacks, the Trap Door will only use Ninth Dimension on Cecil, and the Aegis Shield will grant him immunity to Instant Death.
The targeted party member can use a Light Curtain on themselves using the time between the target and the actual spell cast, which is basically the same strategy as having Rosa cast reflect.
After a few turns (if left un-Berserked), a random monster will come out from the Trap Door.