Like submarines, Attack Submarines are stealthed while moving or standing still and invisible to enemy units except for detectors. They are also detectors themselves, capable of detecting hidden enemy units, including enemy subs and land units like Spies. Attack Submarines reveal themselves only when attacking. They become stealthed again when not attacking for a while (roughly 20 seconds). Light Ships and Helicopters have the ability to detect Submarines and are very effective in destroying them.
When playing island maps like East Indies, keep some Submarines around to intercept enemy landing operations. You can keep them garrison inside a Dock until needed: Build several Docks around your main islands and garrison two or three Submarines inside each of them.
Submarines are deadly against Transport Ships. These units move slowly and are completely defenseless in which submarines can take advantage of.
Aircraft Carriers are highly vulnerable to submarines as they do not have particular strengths in defense.
Vice versa, before starting a landing operation yourself, send Light Ships and/or Helicopters to patrol for enemy Submarines. Helicopters are usually the best choice since the capabilities of submarines are limited to the water they are located in.