Doubt regarding the fact that pressure in a fluid at same horizontal level is same

In the diagram shown, we have taken 2 containers of different heights h and h' where h>h'. These containers are immersed in a bucket filled with the a fluid, say water represented with red color, such that both containers get filled with the fluid. Then we turn the containers upside down and lift them upwards until their mouth just touch the fluid surface of the bucket. Now in the bigger container pressure just below the mouth is ρgh and that at the same level below the smaller container is ρgh'. Since they are at the same horizontal level and the fluid is in hydrostatic condition, these pressures should be equal. so ρgh=ρgh'. Which implies h=h' which is a contradiction to the fact that h>h'. So can anyone tell me where is the flaw in my concepts or the point where i am going wrong? To be certain i did this experiment and it happens exactly as shown in the diagram.

$$\rho g h'$$ is not the pressure at the bottom of the smaller bucket. It is the pressure difference between the top and bottom of the bucket:
$$\rho g h' = P_0 - P'$$
$$\rho g h = P_0 - P$$