It's just not a good way to execute someone. It's slow, gross, ineffective at getting rid of them, inefficient, and undramatic.
How it goes in the movies:
Bad Guy tricks Hero into the airlock, then slams the door, trapping the hero inside. Bad guy outside the airlock pulls the big red lever with the black and yellow danger-chevrons around it, and the far door quickly opens to space, sucking the hero out to their certain doom, where they freeze and/or explode.
This is dramatic! Audiences love this stuff.
How it would go in reality:
Bad Guy tricks Hero into the airlock, then slams the door, trapping the hero inside. Hero seems to have some kind of plan, and starts to don an EVA suit.
Bad guy looks around for a way to open the far door, and sees nothing. He reopens the door, overcomes the Hero, and pulls them out of the EVA suit to tie them up. By chance, he sees the procedure manual for operating the airlock, grabs it, and reads it, cursing, realizing he needs to be inside the airlock to start depressurization.
Following the manual, he begins the pre-breathe protocol, ten minutes of exercise elsewhere in the station, while breathing pure oxygen. After a further 40 minutes of breathing O2, during which he watches an episode of his favorite TV series, he climbs into the tiny airlock with the Hero, and initiates depressurization which sounds an alert throughout the station, but nobody comes running because reasons.
Over a period of 30 minutes and another episode, the pressure drops from 14.7 PSI (1 atm) to 10 PSI (~2/3 atm), at which point an alarm sounds telling him to suit up.
This is equivalent to moving from sea level to an altitude of 10,000 ft in half an hour. The Hero will start to find it difficult to breathe, and may suffer signs of altitude sickness at this point, such as pulmonary edema (fluid in the lungs), cerebral edema (swelling in the brain), and general hypoxemia and hypoxia. He is likely to pass out during this period unless the Bad Guy gives him oxygen too.
Bad Guy, still breathing oxygen, puts on the EVA suit, glad that the hero is well trussed up in these tight confines or he'd be in big trouble. He clips his safety harness to the ring by the airlock, and waits the final 60 minutes for the airlock to completely evacuate, binge-watching two more episodes with subtitles because he can't hear through the suit, let alone through the vacuum that's forming as he watches the pressure slowly drop.
Even with a breathing mask, Hero definitely passes out and dies at some point, his skin blackens with bruising, he swells up and maybe starts bleeding and/or prolapsing from some orifices. Other bodily fluids start exploding out and floating around the airlock, and Bad Guy is glad he's in the suit. They fluids boil, spattering globules as they bubble, and as the fluids boil and gas off, what's left drops in temperature until it freezes in little ice-gobbets, sparkling shards of gore.
Eventually the pressure has dropped all the way. Bad Guy waits expectantly, but the hatch doesn't open, so he walks over and pushes on the hatch. It still doesn't budge. He fiddles with the latches, which seem to work fine, but it won't push open.
He checks the manual and finds that airlock doors ALWAYS open inwards, so that: locking failures cannot cause the doors to pop open under air pressure; and it's impossible to open the door when pressurized, since it would require literal tons of force to open. Sci-fi always gets this wrong, because it's non-dramatic, and because they feel that hatches should open outwards like on tanks.
He pulls, it opens, but there's only a barely perceptible puff of the last remnants of the air going out. Hero's bloated and messy corpse just drifts where it was, up against Bad Guy's facemask in the cramped quarters, both of them surrounded by a halo of gross boiling globules.
Bad guy flails at it and shoves it toward the hatch, but it bounces off and has to be kinda weightlessly wrestled out, all the various bodily fluids going freaking everywhere.
Eventually it's out, and he recloses and latches the door, and begins the repressurization process. This time, he waits the whole time in the suit because he knows it's going to stink out there.
Partway through the next episode of his show, he hears a splatting thud and looks through the airlock viewport to see that the corpse has flown in a slow, graceful loop and splatted back against the closed airlock, losing more fluids which boil and freeze almost instantly. It's drifting away again, though this time in a much smaller circle, having lost in the impact most of the energy with which he threw it out of the airlock. This is because they're orbiting every 15 minutes, and the body is in only a very slightly different orbit, just slightly more elliptical.
Bad Guy is now faced with two unpleasant options. He can either shed the suit here and try to touch as few floating particles of corpse-slime as possible as he escapes from the airlock back into the station, or he can wear the suit out of the airlock and remove it there... but the suit's covered in the stuff too. Either way, the air in the station is now contaminated with the stuff and when he goes through the door, particles will be following him. The scrubbers are good, but they aren't amazing: there'll be droplets of this stuff dried all over the place forever, and the air will from now on always stink of dead Hero dude.
Damnitt, next person he kills will be going into a suit before spacing them, and he'll just cut the air pipes. In fact, screw spacing them, he'll kill them and put them in the trash bags with all the rest of the trash.
In fact, thinking about it, the next person is going to be whoever comes with the resupply vessel, and that might try to come in through that airlock with the hero-corpse floating outside of it... he probably needs to go drag it back inside and stuff it in a trashbag, so's not to tip them off. Crap.
This is... not dramatic. Audiences will not love this stuff.
There're a few cases that designers need to consider when creating an airlock in a spacecraft or space station... or in a novel.
One person accidentally or deliberately cycling the airlock while a second person is in there for cleaning, equipment check, just returned from EVA, etc. Addressed by having the controls inside the airlock; a very slow cycle time measured in minutes or hours; and no doors that lock on only one side. [Edit: this is how it is in real-life craft]
A single person triggering the airlock on their own while in it (suicide, unauthorized EVA, etc). Audible and visible alerts when depressurization starts: "Alert: Port-forward airlock depressurizing. No scheduled EVA at this time." Allow depressurization to be canceled from the rest of the station. [Edit: this case is not covered in real-life craft: depressurization is done from the airlock, venting the air into space until pressures equalize]
One or more people (including rescue personnel) outside the station needing to get into the station when someone has accidentally or deliberately locked the door, overridden the airlock controls, etc; and where all crew inside the station may or may not be incapacitated. Allowing depressurization to be started from outside the ship should address this. [Edit: this case is not covered in real-life craft: the inner door is kept open except during EVA,so you can't "come in from outside".]
A single person needing to get out through the airlock when nobody else in the crew is capable of functioning. Controls in the airlock resolves this case. [Edit: this is how it is in real-life craft]
One or more people needing to operate the airlock from inside the craft, while nobody is in the airlock, is low, and MIGHT NOT be worth factoring into spacecraft design. They can just suit up and go into the airlock to operate it. [Edit: not possible in real-life craft]
One or more people getting spaced by multiple others coordinating together (murderous mutiny or execution). Probably not worth considering, could never be made foolproof anyway. [Edit: not covered in real-life craft, because you can't space someone who's not incapacitated already.]
Hostile boarders: probably not worth considering. Even if space pirates are really a thing in your universe, not even locks and door keys are needed. Space pirates will just magnetically clamp onto a ship and cut through the hull, rather than waste time waiting for some slow-ass airlock. If the victims are lucky, they might pressurize the area around the hole they cut, so people don't immediately die. [Edit: in real life craft, the inner airlock door is always open.]
Everything needs to follow some basic design tenets:
- Minimize complexity. Keep everything as simple as possible, with minimum moving parts, minimum electrical systems, etc.
- Maximize redundancy. At least one fully redundant system for everything. Not just two airlocks, but each airlock having two air pumps, etc.
- Everything should fail safe.
[Ref for some of the numbers: https://spaceflight.nasa.gov/station/eva/outside.html]