There are multiple mechanisms. One of the most common is membrane separation, where C02 is selectively allowed to pass through in a relatively high-pressure, C02-rich source such as a literal smokestack. Others are vaguely analogous to the chemical C02 scrubbers you might find in a submarine or in spacecraft.
At present, it's mostly from high density sources that are producing C02. Membrane separation has been around for quite awhile, and works well for that case. It's largely impractical for capturing C02 directly from the air, though.
Direct air capture is the hard part. The "chemical scrubber" approach is being widely tested, but it's hard to make the whole thing carbon negative. It's a tractable problem, but not an easy one.
An interesting theoretical calculation is the rate of entropy production due simply to mixing of smokestack gasses (high partial pressure of CO2) with atmosphere (low partial pressure of CO2). In principle this is wasted exergy -- lots of it. One could imagine some combination of semipermeable membranes and turbines to extract power from the mixing process (your mention of membrane separation reminded me of this). To be clear this is sci-fi though at this point.
(I do believe, however, that there exist methods to extract energy from the mixing of salt and fresh water.)
Likewise, this same idea is a strong argument for capturing CO2 from smokestacks instead of from atmosphere: Fundamentally, it takes energy to undo mixing. And if you want to capture the CO2 eventually anyway, then better to just do that than invent a theoretical "heat engine" driven by the difference in CO2 partial pressure, to get energy that you'll just need to spend somewhere else later (and then some) to get the CO2 back out of atmosphere...
...Actually this phrase "heat engine" now makes me think that maybe this isn't even that hard (in theory) using cold temperatures and phase changes to make dry ice. If it's possible to efficiently cycle the gas through these large temperature swings at all, it must require some kind of heat exchangers and regeneration between stages... (Surely if this were realistic people would have figured out how to do it by now, but it's an interesting thought/design experiment in thermodynamics...)