UFP Distress Calls
On several occasions we see that the UFP maintain dedicated subspace and radio frequencies for distress signals. These are allied with standard codes ("one alpha zero" is mentioned in TNG: Relics) that are used to instantly identify the signal as a distress beacon. They also appear to have priority levels, with levelpriority one being "ship in immediate distress, render assistance ASAP"...
"...More than an emergency, it signals near or total disaster." The Trouble with Tribbles.
Contacted Aliens :
The Enterprise receives distress calls from previously contacted alien species on a pretty regular basis. I think it likely that one of the first things you would do when establishing diplomatic relations is to communicate common frequencies and forms of messaging including standard warning and distress signals as well as agreeing on codes of conduct (rendering assistance when asked, etc). We see the Enterprise responding to signals from the Klingons and Romulans that are instantly identified as distress calls.
Uncontacted species :
When dealing with uncontacted species, it's likely to be more that distress calls have certain common features. These would presumably include the strength of the signal, the lack of encryption, that the carrier frequencies used are those that allow the fastest and widest communications and the fact that the messages are both pre-recorded and repeating.
A good example would be in TNG : I, Borg. When entering the Argolis cluster, the Enterprise-D detects a signal emanating from one of the planets. Based on the description, Riker's first instinct is that it's a distress call:
DATA: Captain, I am detecting a transmission emanating from within the system.
RIKER: What sort of signal?
DATA: It is self-repeating, of unknown pattern.
PICARD: Where is it coming from?...
RIKER: It could be a distress call. Helm, take us into transport range.