For some airports, under certain situations, there may be a simplified immigration/customs clearance process for domestic-international connecting passengers in Thailand travelling on a single ticket.
The eligible destinations are those with "C.I.Q (Customs, Immigration, Quarantine)" facilities. A recent list can be found on the website of Bangkok Airways:
- Bangkok (BKK)
- Chiang Mai (CNX)
- HatYai (HDY)
- Krabi (KBV)
- Phuket (HKT)
- Samui (USM)
- Trat (TDX)
- U-Tapao (Pattaya)(UTP)
As the website indicates, the availability of the simplified procedure may depend on the airport and the combination of airlines.
For inbound passengers, their bags may be checked through to these destinations and they may clear customs and carry out quarantine procedures (note: quarantine here is not for persons as we would assume nowadays due to the Covid pandemic; but rather in the sense of quarantining and examining live animals and plants before release) in the final destination instead of the first port of arrival; nonetheless, they clear immigration at the first port of entry.
For outbound passengers, they may obtain boarding passes for both domestic and international flights and clear customs as well as immigration at the first point of departure.
There remains an option to clear C.I.Q. (and obtain boarding passes) at the port of final departure from Thailand, in case the airport or the airlines is not able to provide this facility.
how could he be forced to clear immigration while the rest of the plane didn't?
Well, if you ask about how he can be "forced" to do certain procedures: if you want to take a flight, you need to follow the instructions by airport and airline staffs. And if an immigration official orders you to do something, you do it unless you are willing to bear the consequences of disobeying.
If you are asking if mixing domestic and "international" passengers is an issue, then it is not (at least to Thai authorities). There may be certain risks, but it is probably a risk Thai authorities are willing to take, as their presence on the outgoing flight is recorded and shared with the immigration authorities; it is easy to identify passengers who sneak out.
There may be the possibility for a passenger to forfeit the international leg (and therefore avoiding immigration clearance), but that is also subject to the conditions of carriage he has with the airlines.
when the plane landed, could he not just walk out without going through immigration?
Usually there will be staff who will receive the incoming connecting passengers. Additionally, as mentioned above, rulebreakers can be trivially identified and unless the passenger intends to stay in Thailand forever or will only leave by unlawful means, they will encounter Thai immigration again.