No, you don’t quite have it. Subs can always submerge instead of firing unless there is an enemy DD present. In your example, there are no DDs, so both subs are eligible to submerge. Submerging is done instead of firing, before any dice are rolled.
In your example, the attacking sub can choose to submerge. If it does, the battle is over, since there are no attacking units remaining. If it doesn’t, the defending sub can choose to submerge. If it does, the battle is over, since there are no defending units remaining. If neither sub submerges, the attacking sub fires its surprise strike. If it hits, the defending sub is moved behind the casualty line. Either way, the defending sub then fires its surprise strike. Casualties are then removed. Since there are no non-sub units, the combat round is over. If both subs survive, the next round begins and the same sequence of events occurs again.
I think what’s confusing you is the “Surprise Strike” label. The “surprise” only really applies to non-subs and when you have a DD. If you don’t have a DD, enemy subs can always submerge before any dice are rolled.