It is in one massively significant way - on a plane, the mandatory staff responsible for safety are also serving the food - ergo it basically has zero staff cost. That is enough to tip the balance from it being a basket case to it being profitable. There's also an imaginary captive market (a lot of people think you can't carry stuff bought at the airport on when you mostly can, though rules on hot drinks do vary).
If you were allowed[1] pilot-only operation (POO?

) I doubt it'd work quite as profitably for them.
TBH, if I were setting up a train service from scratch I'd combine roles[2] to be more like air stewards/stewardesses, but that's never going to happen on the existing railways, if nothing else the unions would never have it.
[1] It is allowed on very small planes, I've been on a floatplane in Canada that had one pilot as the only member of staff, the safety demo was on an iPad.
[2] i.e. have the first class steward and/or buffet/trolley steward also safety trained as a guard, and involved in the dispatch process etc, and checking tickets as they serve food, rather than one person doing each role. Not necessarily fewer people, just more mixed roles.