The logic is that they don't have to use their surname when they are an HRH Whatever but when they do need a surname it's Mountbatten-Windsor. Archie and Lilibet had the surname MW but don't need to use it now they are grandchildren of the monarch; were their titles removed (just as they are discounted in marriage and other legal matters when the legal surname is required) they would revert to their surname of MW. All names are ultimately adopted and MW was adopted as the family's surname, just as Windsor was decades earlier. It's not that difficult to understand. You see it in the aristocracy all the time eg His Grace the Duke of Devonshire has the surname Cavendish. He'll be Cavendish for all legal purposes but be known otherwise as His Grace The Duke of Devonshire or simply Devonshire. It's standard to have the surname different from the title and to use only the title in everyday matters but the legal name encompassing the surname.
As for the Mars, there are two families with that title. The surname of the Earl of Mar and Kellie is Erskine (I was in the reserves with him when he was plain Jim Erskine, Viscount Erskine, probation officer to trade, lovely but skint guy). The current Countess of Mar was born with the surname Lane but her father had the family name changed to 'of Mar' and the Lane name was dropped. The previous earl to her father also had the surname Erskine, though double-barrelled; her father inherited through a joint ancestor who also had a double-barrelled surname including Erskine. In fact, when Isabella, Countess of Mar, died in 1408 the title was given to the Erskines. An act of parliament was required in 1885 to sort out the earldom inheritance and two were recognised: the Earldom of Mar & Kellie which went to the Erskines and the Earldom of Mar. Of course, you can call yourself anything you like under Scots law as long as it's not for fraudulent purposes so the 'of Mar' acts as such. The 'of' is not really different from de/van/von. The name I go by, quite legally, is not the exact same as on my birth certificate. Scots Law differs from English & Welsh law in many areas, including legal names. I would be very surprised if the entire Clan Mar chose to use 'of Mar' rather than just the family. There's a whole wheen of different surnames in any clan. I certainly never came across it when I lived in the traditional area of Mar though the Gordons were far more prominent, what with the clan chief, the Marquess of Huntly, living in our village. The Mars are based down in England now so they would have been subject to English law requiring legal recognition of the surname. The Earl of Mar & Kellie is still in Alloa though Alloa Tower is in the care of the NTS and Clackmannan Tower is ruins.