S.O.S is a new mechanic in Sun and Moon. When battling a wild Pokémon, it has a chance to call for an "ally Pokémon." This chance increases the less HP the Pokémon has, and a Pokémon inflicted by major status conditions cannot call for help. Pokémon can call for their own species, or other Pokémon in their evolution line.
For example, if a Bagon calls for help, it will call another Bagon. However, it also has a tiny chance of calling a Salamence (at a really low level to boot). In the same vein, Magikarp can call Gyarados, Pancham can call Pangoro, Snorunt can call Glalie, etc.
Under certain circumstances Pokémon, Pokémon can summon Pokémon of different species. One way this works in via weather conditions. For example, in the grass outside of Po Town, all Pokémon have a chance of calling Goomy, but only while it is raining. In the desert area, all Pokémon have a chance of calling Castform or Gabite while a sandstorm is happening.
Other Pokémon will call other species that correspond with their lore. For example, Cubone has a chance of calling Kangaskhan. Or, they can call their predators. Carbink have a chance of calling Sableye and Corsola can call Mareanie — in both cases, the "predator" will attack the "prey," similar how Zangoose and Seviper would attack each other in Horde Battles.
The final thing about SOS battles is that, the more Pokémon of one species that are summoned, the better they are. They have a higher chance of having better IVs, Hidden Abilities, yielding more EVs when defeated, and even being Shiny! The item Adrenaline Orb will increase the chance of a wild Pokémon calling for help.
For more information, read here.