So there is this bug where I would sometimes place a block and then a split second later it would disappear. It would also disappear out of my inventory and then as soon as I get another of the said block it would just magically re-appear in my inventory. I have no idea how to re-create this bug because it seems to happen at random times. Although it think it might be caused by mobs standing to close to the block you are placing.
Related issues
Comments

Thank you for your report!
We're tracking this issue in MC-163637, 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 in the future to see if the issue has already been reported.
Quick Links:
📓 Issue Guidelines – 💬 Community Support – 📧 Customer Support – ✍️ Feedback and Suggestions – 📖 Game Wiki
I think that happened because you might have a slow/laggy computer