The carrier has no actual direct interest in your medical details. However they are often required to verify documentation by the authorities of the country you are travelling to and can be fined if they don't do that correctly. If they let you travel without a visa when you need one they get fined (plus they may have to fly you back again). Likewise there can be penalties for carrying an unvaccinated passenger when that is mandatory. So this information becomes their business by law.
This methodology operates all over the world. If you don’t like it, don’t travel.
I shouldn't have to choose between (non-) treatment and travelling, and I have no plans anyway while "new variant" stunts are being pulled. The trouble is, a lot of airlines operate parallel to railways, sometimes domestic, and there are issues with domestic and/or non-transport function creep as well. I have other reasons for not using the NHS app; not least because I don't want a device tracking me. If any authorities want to do track me, they can go the long way round.
The carrier might also find that they are taken to court and forced to "choose a country" and they have to stop serving countries that coerce medical treatment. Yellow fever prophylaxis would be a classic example, as there isn't much worthwhile treatment. However, I will concede in part that most judges make it up as they go along to suit an agenda so the whole legal system is screwed. However, such things are not not entirely unprecedented... for instance one cannot direct-book flights between the UK and Syria.
Forcing people to have prophylactic treatment is precisely the kind of rubbish that I dropped out of medical school to get away from. Modern medicine is useful, but sometimes over-rated. Healthcare generally is a good servant but a very poor master.
Besides, the example I have been using - on facebook with my real name - is to compare such things to abortion - if that is OK then it's also OK to decline any treatment other than abortion, as one cannot match the level of malicious intent in having (let alone performing) an abortion by declining any prophylactic treatment. Trust me, the comparison I use on facebook is much more blunt than the previous two sentences!