The most niche of all the Sea Units, Subs are effective at ship hunting and scouting, but little else.
Subs excel at naval combat; they deal high damage to all Sea units, with the exception of Cruisers. Cruisers must be avoided as they can deal very high damage to Subs while taking little in return, regardless of which unit gets first strike. Subs are completely incapable of attacking Land or Air units.
Subs are unique with their Submerge command. When told to Submerge, Subs become invisible to enemy forces, only revealing themselves when any enemy unit is adjacent to the Sub. Additionally, submerged subs may only be attacked by Cruisers and other Subs but, in exchange for these benefits, they drain their fuel much more rapidly (5 fuel per day compared to 1 fuel per day when surfaced), meaning Subs may only stay submerged for a short amount of time before needing to refuel from a Port, Black Boat, or APC. With their ability to submerge and high vision, Subs make excellent scout units in Fog of War where Sea units are viable.
Since they are completely reliant on the enemy building a Navy in order to be effective at any capacity, Subs are one of the rarest units to see built on AWBW. It may be wiser to invest in other units, even if your opponent is building Sea units.
Subs are fairly standard units when they are surfaced; most Sea and Air units can deal moderately high damage to Subs if they can attack first. When a Sub dives, it becomes a much larger threat to any Sea units around, especially Landers. Use the game's Log to verify when and where a Sub dives, and avoid leaving any Sea units exposed in that general area. Since Subs cannot attack Air units, Copters may prove useful in blocking a Sub from attacking any Ships in the area. Otherwise, deterring Subs with Cruisers can prove effective as well.
Subs can only stay submerged for about 7 or 8 In-game days before running low on Fuel, so limiting its attacking capability for a while will eventually force it to resupply, possibly surfacing in the process. Since most games are won in the Land and Air battles, not the sea battles, it may also prove worthwhile to invest in those units instead of trying to counter a Sub, unless Landers or Battleships are critical for the battle.