For WWII specifically, anything written might not actually be sent. V-Mail services photographed letters, reduced them onto microfilm, and reprinted them overseas. A lot of people were sending a lot of mail and paper is fucking heavy.
AFAIK, addressing worked about the same way it works now: you’re given an address for a specific person, at a somewhat-abstract location. Sometimes it’s a very concrete place - no pun intended - like a permanent airbase or an actual city. Sometimes it’s a boat. Sometimes it’s a “forward operating base,” which falls somewhere between no-fun-allowed paintball facility and Burning Man with more grabassing.
APO – Army/Air Force Post Office. The Military Post Office for Army and Air Force personnel
FPO – Fleet Post Office. The Military Post Office for Navy and Marine personnel
DPO – Diplomatic Post Office. The preferred designation for mail addressed to Department of State overseas post offices.
MOM – Military Ordinary Mail. Mail originating from the Department of Defense.
MPO – Military Post Office. Provides postal services for military personnel.
PAL – Parcel Air Lift. An expedited service for Package Services is available for an additional fee.
Anyway you can also send “unit boxes” for a whole group, but I think you’re still supposed to address them a specific individual.