When off-handing (default key is F) and placing a block in the same tick the item gets placed for a very short time on the client which makes "ghost blocking" or "ghost lily pads" possible.
Despite this the item still exists in the inventory which means this can be done infinitely (albeit it very hard to do).
After pressing the offhand key once and placing the first block, in order to keep going you need to from then on press the offhand key twice in order for it to work.
This probably relates to these bug reports:
Thank you for your report!
We're tracking this issue in MC-256440, so this ticket is being resolved and linked as a duplicate.
If you would like to add a vote and any extra information to the main ticket it would be appreciated.
If you haven't already, you might like to make use of the search feature to see if the issue has already been mentioned.
Quick Links:
📓 Bug Tracker Guidelines – 💬 Community Support – 📧 Mojang Support (Technical Issues) – 📧 Microsoft Support (Account Issues)
📓 Project Summary – ✍️ Feedback and Suggestions – 📖 Game Wiki