I haven't studied the HSMS Gotland incident in any great detail, but just in general for wargames, ships are required to be in certain locations at certain times, stay inside sea lanes, use transponders, ignore certain other ships and in general not completely mess up the existing sea commerce traffic that is trying to go past the exercise area.
If your carrier group is literally 1000 miles away from any piece of land and you have full authorization to sink anything that looks even slightly suspicious, it probably becomes considerably more difficult to sneak up and torpedo a carrier.
But yes, carriers will get sunk, modern warfare is in large part attritional, but if you send out, dunno, $100m worth of subs and sink a $10b carrier, that's a great return on investment, but doesn't help you in the slightest if you're now out of submarines and the enemy sails two more carriers into range.