Is there any way to avoid this seed planting bug?
It looks to me that it isn't a bug that's causing the seeds to pop out, but your lack of lighting. If an area is too dark, seeds will pop out. I don't know why the other one pops out too, but you can at least try to increase the lighting. That should fix the problem.
I have had this problem, when i would plant seeds, they would pop off. Its the lighting, as you may need to add a torch or glowstone above the dirt, and it should fix this issue. By the way, to make a torch be in the center, you build a small tower, about 3 high, (depending on the ceiling) then 1-2 blocks to where the center of the dirt and crops are, then you place torches on the block(s) and remove the tower.