Checking collision right before creating an object/setting a tile

Hey, so I have this mechanic in my game where the player can create and destroy blocks.

The problem is that when I create a block :

    self.is_creating_block = true
    tilemap.set_tile(tilemap_id, tilemap_layer, tile_pos.x, tile_pos.y, 2)
    go.set_position(check_collision(self, go.get_position()))
    self.is_creating_block = false

It seems that the tilemap is only updated AFTER everything runs.
I want to do a collision check after creating a block to push the player if a block is created over the player.

I tried using a factory with tilemap.set_tile and game objects, and both behaved similarly.
How should I do this?