Off-hand actions would not perform if there is a block in the main hand even if the main hand action is invalid.
Hold a block in the main hand, torch in the off-hand.
Aim at the block directly beneath you.
The torch cannot be placed.
Using a composter
If you go very far back (~1.9, 1.10), when dual-wielding was first introduced, this wasn't the behaviour.
Intended behaviour would be:
1. Try to perform main hand action
2. If invalid, try to perform off-hand action
It seems that some code in the block placing function was messed up and prevented the check for (2).
It seems that this bug was introduced between 1.10-1.16
Speculation would be that this is due to 1.13 water changes and the code for waterlogging blocks somehow interfered with the block placing function.