Exactly how the selling of another airline's seats works depends on the agreement. Airlines like it because they get to keep a commission for selling the seats, plus they then get the connecting passenger traffic on their own flights. So, using the Thai Airways example, if AC sells a ticket from YYZ-LHR-BKK, they get a commission for the LHR-BKK portion and force the passenger onto their own flight to London. Otherwise, the passenger may fly the competition to LHR, or maybe even fly UA or NW all the way transpacific. Thai also codeshares with AC, so the reverse happens.
The concern with the AA/BA alliance is that these two airlines would then operate the majority of the flights from the US to London, and could use their market dominance to squeeze out competitors and raise fares.