Simonb is down to a subconscious fear of ridicule if you make a mistake
Hmm, I think this really depends on the person.
I have been trying to get past the "shaky hands" for years, and one of the biggest challenges was always that I don't have enough chances to experience playing for others.
I'm not afraid of ridicule. I know no one will ridicule me if I make a mistake. And I don't ridicule myself. I have a pretty matter of fact view of it. I'll play as best I can, and that's great. I probably won't ever give my best performance in an actual performance situation (i.e., I'll always play better when I'm at home, on my piano, fully immersed, concentrating with no distractions). But I'm ok with that too. Even if I don't play my best, it can still be enjoyable for the listeners and for me. So I don't think fear of ridicule applies to everyone. Although maybe self-ridicule is another factor.
For me, I care deeply about playing well, and a performance situation (no matter how casual) is loaded because you basically have one shot to get it right. That's a lot of pressure, which for me comes out as shaky hands, along with blank-brain (the experience of just getting lost and not know where you are in the music). Over the years, as I've had more chances to play for others, I've gotten better at mitigating the impact of this pressure on my playing. Covid kind of screwed things up, and then moving to another state, but I'm getting into having more musical activities now. So I'm confident that just exposure (performing more) will help me continue to get better at that mitigating. I also (again, matter-of-factly) recognize that it's not going to go well every time, and that's ok. The better I get at reducing the pressure, the more the shaky hands will become irrelevant.
Simonb A final point I'd mention is sheet music. When I'm playing to my teacher I'm reading sheet music. My reading is pretty good, but not great. I think the reading of music is a contributory factor in people struggling with nerves.
This also is very individual. I have found that I do better (i.e., am less impacted by nerves and shaky hands) when I read the score while performing. I'm a strong reader, and knowing I have the score there relieves the pressure to memorize, gets rid of the fear of memory slips.
Also, for me, I've found that training myself to keep my eyes on the score and read along gives me something to distract myself with. By reading, I am able to be more successful at staying focused on the music, which translates into a better performance.
So the trick, I think, is for each person to figure out what works best for them. Trial and error is needed. Which can be problematic for a lot of hobby players because a yearly recital is no where near enough to do any meaningful trial and error.