Page 12-13 of the Europe rule book
The general rule is that you can’t move units in the combat movement phase if it doesn’t result in combat.
“During the combat move phase, all movement must end in a hostile space, with a few exceptions (see below)”
The closest exception is regarding hostile sea zones, but a sea zone with only subs/transports is not hostile.
Exception #2, bullet point on page 13
“Units moving from a hostile sea zone to escape combat as their combat move. A sea zone into which defending air units may be scrambled in reaction to an amphibious assault may be treated in the same was as a hostile sea zone for this purpose.”
Exception #3
“Sea units that will be participating in an amphibious assault from a friendly sea zone, as well as sea and/or air units that may be needed to support it in the case that defending air units are scrambled”
So it is only legal to move ships away from a zone with a sub in it, during the Combat Move phase, if those ships will be possibly participating in combat. If you can’t move them away during the combat movement phase and you are going to engage the sub, then those ships will necessarily be involved in the sub battle, so cannot move in the noncombat movement phase.
Attack the sub or move the ships, you can’t do both because it is not legal to move ships away from a non-hostile zone in the combat movement phase if those ships are not making a combat move (going to attack or support an amphibious assault).