@dis_rain Because the amount of water a cell can hold not only depends on its neighbors but also depends on the neighbors of its neighbors (the lowest height that is greater than its height). Think about this scenario: the height map is:

[
[5, 5, 5],
[5, 4, 5],
[5, 3, 5],
[5, 5, 5],
]

The amount of water it can hold is 3, of which 1 unit is held at [1, 1] and the other 2 unit is held at [2, 1]. But when we calculated the water of [2, 1], we need to treat the height of [1, 1] to be 5 rather than 4 to get the right result since after filled with water, cell [1, 1] can actually hold water of the hight up to 5.