trying to detect water or lava relative to the player fails if the block adjacent to the fluid where it would spread to just changed. (green block in picture)
If the block didn't change for the time the fluid would spread "execute if block" will work again.
In this example I use an advancement for mining cobble from a cobble-generator. It uses the inventory_changed trigger with item cobblestone to grant a function as reward that tests if the player is at a cobble-generator.
The according test for the situation in the picture is:
execute anchored feet if block ~1 ~ ~1 minecraft:water if block ~ ~ ~2 minecraft:lava run scoreboard players add @p adv_cobblegen 1
execute anchored feet if block ~1 ~ ~1 minecraft:water if block ~-1 ~ ~1 minecraft:lava run scoreboard players add @p adv_cobblegen 1
(all other orientations behave the same way)
This fails if the player mines cobblestone from the green blocks position. But it succeeds if the function gets called manually or the inventory changes with still containing cobblestone. Booth only if the green block did not change recently.
Have you tried
flowing_water
/flowing_lava
?