I tend to automatically want to call officials and clerks "Sir" because I am usually their junior, but instead they are calling me "Sir". When is it appropriate to call someone "Sir" or "Madam" in a UK context?
As Lambie said, you can address them without any title, and it will not seem rude or out of place. If you believe you're younger than them and wish to call them "sir" or "ma'am" out of respect for their age, that's also perfectly fine and polite. If you choose not to do so, that's also just as fine. Bear in mind that respect isn't just through words, but also through tone - so you can speak to them without using "sir" and still come across as perfectly polite and respectful.
Do bear in mind that they call you "sir" for a different reason - that is to respect the fact that you're the recipient of the service they're providing (i.e. in a customer-facing role they're instructed to address the customer with respect, irrespective of the age of the customer).
So, each of you are calling one another "sir" for different reasons which can co-exist and can still be used. Of course, the conversation might get awkward with many "sirs" flying around, so you could limit the "sir" to the initial greeting and final thanks, if you wish.
Don't sweat it, no one is going to be offended by politeness. We could all do with more politeness in this world :-)
In general, in the UK, it is polite to address anyone in a hierarchical relationship who is higher than you as "Sir" or "Ma'am". (That last word is pronounced the way an American says "Mom") That is why a clerk calls the person being served "Sir" or "Ma'am": s/he is a public servant, after all. But I should think that you could call the clerk Sir, or Ma'am, certainly if you are obviously junior in years. The one ABSOLUTE exception to this rule is that you should NOT address your father as "Sir". (I should say that YOU should not; I do not know how Prince William addresses his father, King Chsrles. Luckily, I doubt he needs my help to learn the correct answer). Just to clear one last confusion on this subject, children also don't call their mother Ma'am (pronounced "Mom" :)). They generally call her "Mum" or "Mummy", I believe. (One can use that last title even for a mother who is perfectly alive and not yet embalmed :))
I am an American who lived for a total of 9 years in the UK, at two different times. I remember television-news segments during the Falkands War which showed British soldiers addressing (then Prime Minister) Thatcher as "Ma'am"; each instance produced shock/horror/wincing among all my (Oxford) friends; they told me you only call the Queen "Ma'am". I saw exactly the same reaction several times when an American friend was with his father and addressed him as "Sir."
I checked several (British) dictionaries and style guides, and they all mentioned one thing that suggests my Oxford friends (described above) had less respect for Mrs. Thatcher than for correct English usage. Although indeed Ma'am was the correct way to address Her Majesty the Queen (but only the second time one does so in a conversation; the first time one must use "Your Majesty"), it was also correct to address other women this way, when you are both in the same hierarchical organization (such as the military or the police), and the person being address has higher rank. I don't actually know if the British Prime Minister is also "Commander and Chief" of the Military (as the US President is); but I can imagine that some British soldiers might well think so, and would therefore quite naturally have addressed Mrs. Thatcher as "Ma'am".
In the UK, shop assistants often address customers as ma'am. It is certainly not used only when addressing Her Majesty. Jul 29, 2017 at 18:04
I think it might be a good idea to update your first paragraph with the corrections you discovered and listed in the last paragraph. Specifically, ma'am is correct in lots of situations, pretty much wherever sir would be: addressing customers, addressing superior officers within the armed forces etc. May 21, 2021 at 13:02
To address your last point, the commander-in-chief of the British armed forces, to whom service personnel swear loyalty, is the Queen (and, for instance, Princess Anne holds numerous senior officer ranks), and both of them are correctly addressed as ma'am both in civilian and military contexts. It is indeed conceivable that service personnel might address the PM or Secretary of State for Defence as sir or ma'am but these individuals are civilians are hold no rank: it's just as valid or not as addressing any other civilian that way. May 21, 2021 at 13:04