I know this is not a common scenario, but it's quite scary.
Imagine that you are travelling from the UK to Australia, and you intend to respect all laws in both locations. In both, you are allowed to carry Valium, codeine, alcohol, or porn with you.
However, due to an unfortunate technical problem, you have to land in Dubai, or in any other country with quite different views on what constitutes a crime. Everybody has to exit the airplane. Wouldn't you just be in dire straits now? Either you get rid of all the stuff, in a discreet way, or, you risk imprisonment.
Could this happen in real life?