How can this not be illegal
There's usually a caveat in the legislation surrounding this about the passenger being " self reliant" or not.
If someone can communicate with the crew, look after themselves (loo etc, ) and get to an emergency exit unassisted the are usually be regarded as "self reliant" and are OK to travel alone.
If OTOH the individual isn't self-reliant ( for any reason) there's usually a mandatory requirement for a travel companion.
Turning your comment on it's head it's possible it would have been illegal for the airline in question to carry him "solo".