It's because the strong feelings of embarrassment happened at the same time as a sexual stimulus. On its own a mild sexual stimulus, like getting naked in front of a doctor, should not cause a strong arousal for most adults. But if the powerful emotions of fear, anxiety or embarrassment are present from other stimuli, the mild sexual stimulus can cause a powerful arousal too. It's called excitation transfer. The excitation from one thing is transferred to another, intensifying it and making us think they come from the same source.
Excitation transfer is why some couples have angry sex after a quarrel, and may be why soldiers get very horny before and after battle, with historical consequences.
The strong sexual memories are often etched into our minds when we are young. As adults, we are more thick-skinned so few things faze us or embarrass us enough to transform a minor sexual stimulus into intensified arousal.
I would add that the feelings are even more intense when both stimuli are somewhat related. For instance, the embarrassment may come from a loss of control of one's body, which parallels the sexually submissive instinct of giving up control of one's body to another.
There was always a sexual element present when I look back at the embarrassing memories that still arouse me. I don't get aroused recalling embarrasment from public speaking mishaps because there was no sexual stimulus present.
I remember my first embarrassing episode at the doctor's office very clearly because my brain was hyperaware of everything that was going on. It was a series of surprises and shocks that stimulated anxiety and embarrassment in equal measure, in effect, excitations from multiple sources. They were strong emotions yet I kept my presence of mind and can still recall the thought processes that went on in my head.
As I lay on the examination table I remember it being so comfy that I could sleep on it; it was more like a cushioned bench than a table. I watched the doctor giving instructions to a nurse who then took something out of a fridge and handed it to him. I felt the first pangs of anxiety because I thought they might be preparing an injection. The first shock came when another nurse, who was tall and stout, suddenly reached for my waist and pulled my pants and panties down, without so much as a warning, much less gentle words to enlist my compliance. I felt my bare buttocks jostle and stick against the black padding of the table as she roughly pulled my clothes off. I said "Wait!" and tried to stop her but it was too late. Time seemed to slow down as I watched her hands sliding my clothes past my knees and beyond my reach. This was probably the first embarrassing excitation which came from a loss of control. I felt a bit of fear too from the nurse's rough handling of my body. I lay dumbly on the cushioned table with my arms at my side, too stunned to know what to do, but the thought ran through my head to keep my legs straight and together because my crotch was now exposed. There was already a sexual element present from my nakedness, but it would only become worse. The next shock came when the big nurse crossed my ankles, cupped her hand under them, and swung my legs upwards. I wondered why she wanted to see the back of my legs, but when I felt the cold air between my buttocks, i realized in horror she was doing it to expose my nether parts. That is my earliest memory of being put in the diaper position. I could only shift my knees together to naively try to limit the exposure but my butthole still felt very much in the open. I was now in a sexual pose with both my genitals and anus on full display. No doctor would admit that this is sexual but my body and brain unconsciously knew it. I was probably blushing because my face felt warm, but my fingers and toes felt numb from the shock of it all. The embarrassment, anxiety and the sexual posture rolled into one is probably what seared the incident into my memory....one huge combined excitation. The nurse stood to the side of the table holding my legs up with one hand that gripped my ankles tightly. She looked at me with a cold expression on her face, perhaps expecting a struggle and challenging me to resist, but I didn't because of the fear rising in me. My mom had been giving me suppositories so when I heard the familiar crinkling sound of the foil being unwrapped, I knew what to expect. When the doctor and the other nurse approached the table, the big nurse lifted my ankles higher to give the doctor easier access to my butthole. I felt the stretch in my back because my hips rose off the black padding and I remember my ankles hurting because she was gripping them tightly. This distress was probably another excitation that added to the sexual arousal. At least the discomfort distracted me from the embarrassment. I almost cried from her brutish control of my body but I stopped myself because I felt I had to put on a brave show in front of the doctor and nurses. I began to calm down. As I waited for the touch on my butthole, I tried to distract myself by looking at the patterns on my shorts that were now around my knees and in front of my eyes. I tried to break the awkward silence by asking the doctor if it will hurt, but deep down inside I wanted to tell him to be gentle with my anus. Then I felt the coldness of the suppository entering. He didn't insert his finger deeply because it did not hurt like mom's. Their job done, the nurse dropped my legs back onto the black padding. She may have told me to put my clothes back on but she did not help me get dressed. I had to pull my shorts and panties back up on my own. This was the final embarrassing moment in this incident.
Interestingly the memories of the suppository insertion do not excite me, perhaps because I was calm and expecting it. It was the buildup to it that was scary and embarrassing and probably caused excitation transfer from multiple stimuli to my unconscious sexual arousal. And after the insertion, the embarrassment of being watched while I got dressed and tried to salvage whatever modesty I had left, also turns me on.