do you mean how can lungs work after they are removed? Like a transplant? I’ll assume this is what you meant and try to answer you.
So lungs, and indeed many other organs can survive being removed from a donor body when they no longer need them and will work when they are transplanted into someone whose organs have failed. the case only if the organ (in this case the lung) isn’t damaged or diseased in any way and as long as it is kept cool between one patient and another.
One example that I find incredible is the liver. For most organs unfortunately someone has to die before they can donate. However, the liver is an exeption since we can take part of a liver from a living healthy donor and it will re-grow to form a fully functioning liver in the recipients body.