There are those that have never handled a gun, especially a couple of kung fuy type martial arts types I have known that I'm thinking about, think shooting a handgun is so easy it's cheating and you're a wussie if you resort to one. They're like the folks that think you don't have to know how to point a shotgun to kill a bird or hit a clay target. It just annihilates anything in the general vicinity in front of it, or something like that.
Well, as you found out, there's a lot more to it than that. Read up on marksmanship technique, breath control, trigger control, proper stance, etc. Use a two hand technique, either isosceles or weaver/modified weaver. And, practice, practice, practice until you can put those words into actions. Or, you could seek out some instruction, but you can learn it on your own. It will take more than a few range sessions to get proficient, but you'll start to see improvement soon.
Proper hold can reduce the "shaking", but not totally eliminate it. One hand shooting as the bullseye guys do, you sorta shoot when the sight finds itself over the bull. LOL For bullseye, a precise trigger is very important. The two hand techniques will reduce the shake, but not totally eliminate it at extended ranges. The same shake occurs with a rifle off hand, but even more reduced, but it's still there and there in lies the challenge of marksmanship. It can turn into a never ending quest for perfection. Others, like me, get mildly proficient and say "screw it, good enough".
To really, really be on top of the game, even after you've become proficient, you have to burn a LOT of ammo. The guys you see shooting on outdoor channels and ESPN in the shooting games like IPSC go through handguns like a baby goes through diapers. They wear out a gun in less than a year that would last most of us duffers a lifetime. Like me, you may never be that good, but you can be proficient above the average, sufficient to protect yourself if the time ever comes or even to hunt big game with a handgun. And, nothing against the martial arts, but unlike Karate, an 80 year old in a wheel chair can use a gun for self defense effectively. At 52, physically, I'm getting past my prime, but I can still shoot! And for women, nobody ever raped a .38. And, I mean, even the martial arts of the time used the most modern weapons of the time, swords, nun chucks, etc. Well, we ARE in the 21st century after all.