Whether the unit is considered underwater is a single point (the root bone, that usually has the name of the unit), where as each weapon determines on its own whether it is underwater. The former is used to determine intel and whether the target as a whole is legit to shoot at. See also the field FireTargetLayerCapsTable
in a weapon blueprint. This is a fundamental flaw in how the game works, and sadly it shows up more the bigger the unit is.
From a script perspective, you could check and verify for experimental units that they're not idling near a shore. Occasionally polling every 5 to 10 seconds should suffice. That way users are at least not confronted with this behavior, but you can't prevent users from doing it themselves