Say an airline alliance has airlines A, B, C, and D.
I have only registered for a frequent flier account for A. I am booking on C. When I book on Expedia, I have a dropdown option for basically every frequent flier program in the world, not necessarily what will be supported (certain things that obviously wouldn't be supported, like another airline not in the same alliance).
I select the frequent flier program for A, and enter my number for A in the text box next to it, and finish booking the flight on C.
How often / in what cases does this work? I tried it recently, but I just checked and the miles weren't credited. I didn't take the flight yet though, so maybe they will be credited after I fly.
If it is really case-by-case, it's hard to see how this would be a viable strategy since there are too many possible combinations to remember.
But if it DOES work then it is probably the only way to accrue decent frequent flier points if you 1) only fly 2-4 times a year, and 2) always take the cheapest flight regardless of airline. The alternative (signing up individually for every airline you use) won't work since you'll have too few flights, they will expire, etc.