I'll try my best to answer this, as someone who doesn't know explicitly what you're thinking about. I can only really guess what you're referring to without hearing explicit details but:
Since you're into anatomy, and please don't doubt what a geologist might know about anatomy, as geologists sometimes double as anatomists and we work closely with anatomists, as anatomy is of course significant to paleontology...
But anyway, if you're into anatomy, Neil Shubin, who perhaps you have heard me reference before, happens to be an anatomist. He knows a lot about anatomy and has written several books on anatomy and has published on anatomy etc. But he also doubles as a paleontologist, which means that he works closely in conjunction with geologists, to synchronize our research. As a matter of fact, I can attest to his geology and paleontology related work, as our community isn't the largest and often we look at the same bones and rocks and work with the same people.
And one thing Neil regularly says, and supports through discussion of anatomy, is that, he often talks about the idea of "useless organs", much like you appear to be discussing now.
He gives several examples of "useless organs". Basically saying, how could evolution form X, Y, and , Z complex organs/functions/processes simultaneously?
His common example is in relation of course to the fish to amphibians transition. He says: in order to a fish to evolve to walk on land, it would have to undergo a massive transformation. It would need to go from water breathing to air breathing (where would it's lungs even come from). It's fins would have to evolve to limbs, fish would have to undergo dietary changes and digestive track changes, circulatory system changes and really a whole host of simultaneous changes that seem like an insurmountable feat for the theory of evolution.
And this is at best, all I can guess you're referring to.
But in Neil Shubins books, he then proceeds with tackling these topics, as an anatomist, specifically describing history of anatomists and their findings, and linking them to modern day anatomy research, and then tying them in with geology via paleontology (which is really just comparative anatomy and morphology).
And I would highly recommend reading his books. Here is one that is maybe 90% purely talk about anatomy:
https://www.amazon.com/Some-Assembl...8510285&sprefix=some+assembly+required&sr=8-1
But actually his books go into a lot more detail even beyond anatomy, but more specifically about how genes are altered, thereby altering proteins and further how the timing of development weights in along with triggers which can drastically transform the anatomy of an animal in a viable manner. Of course single gene mutation and the timing of anatomical development through altering genetic triggers can be the difference between an animal having two limbs or 4 (he lists several examples of drastic morphological changes and specifically how mutations account for them).
So anyway, to answer the question though, of how evolution accounts for what seems to be an impossible feat, Neil describes, in anatomical detail, one by one, some of these features (obviously you can't write about all of them otherwise you'd be writing a million page book), and how they formed.
And in most cases, it's not that evolution generated all of these organs out of thin air, but rather that they typically pre existed and simply served alternate functions.
And I'll give an example shortly, just have to grab some coffee.
And I think this is great because you explicitly mention respiration, so I'll talk about respiration as it pertains to anatomy.