Yep, it's the while loop. The while loop only checks random_cell not in block_array, ignoring the gold_x_y check that got you into that branch in the first place. So once in the loop, it can land right on gold_x_y, since nothing in there is excluding it anymore.
I'd ditch the while loop. Build a list of the cells that are still empty, so cell not already in block_array/equal to gold_x_y, then pick a random one from that list.
I also don't see anything in this snippet that sets the cell you're hovering over with a dragged tile as occupied, so it might be worth checking whether that's handled elsewhere.
That first if statement is weird. I'm guessing it only fires once for the first block you spawn, assuming countdown_iteration never gets reset to 1 elsewhere (that would be bad, spawning tiles without checks). The general logic should be able to handle that case just fine on its own so triggering a spawn from here makes no sense. You can still keep countdown_iteration for whatever, just have it run at the bottom instead of gating the spawn logic.