execute if entity @s[tag=south] run fill ~1 ~ ~1 ~-1 ~1 ~1 iron_bars[east=true,west=true] replace
execute if entity @s[tag=north] run fill ~1 ~ ~-1 ~-1 ~1 ~-1 iron_bars[east=true,west=true] replace

execute if entity @s[tag=east] run fill ~1 ~ ~-1 ~1 ~1 ~1 iron_bars[north=true,south=true] replace
execute if entity @s[tag=west] run fill ~-1 ~ ~-1 ~-1 ~1 ~1 iron_bars[north=true,south=true] replace