Here is an example of HOW a unit COULD end up firing BEFORE the desired WRA distance is reached:
I have a Hornet on a bombing mission. (This aircraft is unimportant.)
It is being ESCORTED by a Prowler which is jamming.
Both the Hornet and the Prowler are originally flying at 36k feet and are over 100 miles from their target.
The Prowler is also armed with two HARMs, and the WRA is set to fire at 30 miles. (They don't want to alert the enemy too soon of their presence.)
The Prowler (ON ESCORT DUTY) has to have its TARGET OF OPPORTUNITY checked so that it can shoot at a radar unit that is known to be next to the target (a group of facilities).
The Prowler picks up the enemy radar (actual one is not important) and identifies from a great distance.
As the group gets closer, the Prowler KNOWS exactly where the radar is, but isn't close enough to fire as of yet due to its WRA limitation of 30 miles.
At about 60 miles away from the target, the Hornet drops down to 200 feet to begin its attack run.
The Prowler also drops down to 200 feet as it is escorting the Hornet.
When the Prowler drops down, its fix on the radar unit starts bouncing around. (This is the critical part.)
The Prowler has already identified the radar as being the enemy, but its location is no longer solid. It's now displayed in a rectangle because the Prowler's altitude is too low.
As the Hornet and Prowler continue their approach, the radar unit's location continues bouncing around.
The Hornet and Prowler are now about 45 miles away from the target and the radar.
At this point, the radar (while bouncing around) now bounces to a location within 30 miles of the Prowler.
Knowing that the radar is the enemy, and is now within the 30 mile WRA limit, the Prowler fires a HARM at it.
When the Prowler fires, it is because a KNOWN target is within the WRA range of 30 miles.
As the HARM is flying, the target's location jumps back to its actual location, which is still 40 miles away.
The HARM adjusts to the new location with no problem.
By firing its HARM so soon, the enemy now KNOWS of the existence of some kind of enemy (the Hornet and Prowler), and scrambles some fighters from a nearby base.
This was NOT DESIRED as the Hornet needed to have lots of time to perform its bombing run on several facilities, and now must do so under duress.
The purpose of this was to describe how a unit, even with a WRA set at a certain limit, could fire before you actually want it to.
I will provide a save if you desire when I have access to the game, but it is pretty easy to replicate.
Granted the OP's example involved a sub, but the two events COULD be related.
I wonder though if you can avoid that with in addition to setting the target of opportunity, if you engage the doctrine option "engage ambiguous target" and set it to ignore, I forget offhand if that actually ignores the ambiguity issue entirely, or tells it to ignore targets that have any ambiguity. If the latter it could help, if the former I wonder if we need something like the latter as an additional override.