I see the misunderstanding now.
HRH meaning his/her royal highness is not the form of address used for the monach that is HM (his/her majesty). I must apologise for using the word "title" when I should have used "form of address" as English is not my native language.
People certainly swear loyalty to their monarchs in their countries when they join the military or become a minister or other contexts, but that doesn't mean having a title with the royal or imperial highness form of address (not all titles imply being highnesses) is "a constitutional position that comes with income, military ranks" meaning they get money or that they are related to the military just for being highnesses, which is what I thought you meant, but I see now that's not the case.
Any interaction with the royal family is clearly defined by the protocol for the specific situation but protocol is certainly not the same as law, thank God, even if no doubt someone from the military would get in trouble if they didn't salute a member of the royal family in an ceremony of any kind of public ceremony/oficcial context just like they would if they took out their mobiles and started texting in the middle of a parade.
In short, breaking the protocol can be inacceptable, but it's not the same as breaking the law.