Well, how would they know how to fly it back? Even if you had researched UFO navigation, your squaddies wouldn't necesarily have learned it, or it might not even be possible to control the spaceship without having the right Psi-abilities / mind vibrations.
To answer your question, how would they know how to fly it back? The same way they already do.
UFO Navigation: https://www.ufopaedia.org/index.php?title=UFO_Navigation
Alien craft use sophisticated computers to navigate on earth and through space. The system is based on optical processors arranged in network fashion. The control interface is relatively simple - the navigator controls the direction of gravity waves generated by the power source to move the craft in any direction. This system can be used easily by humans, and it can be reproduced using alien alloys and other components.
Currently if an Avenger lands on a landed UFO and completes a mission successfully, all UFO/mission items are immediately available in the store. So someone is flying or moving it back, at least as fast as the soldiers and aircraft/Avenger flies (which is very fast). I would imagine the soldiers have some sort of radio contact communication method to get instructions from base in how to fly and operate the UFO back to base. This same method can be used to fly the UFO back to Earth.
What I am thinking is that each soldier IS in constant communication with their home base. Actually you are the commander, and the tactical game screen itself is you being the commander viewing the battle scenario on a monitor. Your moves and actions are obviously you - the commander - giving orders to your units. This part is clear, and they would have the entire base's resources at their disposal. I imagine that higher rank soldiers within your squad will already be familiar with UFO Navigation and the recovery process. In Cydonia this also makes sense as we already have HyperWave decoder technology and it makes sense they would have instant communication (via "supre-dimensional wave which travels instantaneously"). This is also evident in the fact that we can control soldier orders and movements. If all soldiers die, you loose control and cannot issue any more orders because base communication is cut, and immediately view mission failure screen. This must be the process.
I was thinking about this yesterday, how would the soldiers know to fly the UFO back? Surely there definitely isn't a separate "recovery unit" being dispatched. This is definitely not the case because when completing a mission with an Avenger, all UFO items are immediately available. That would mean if there WERE a recovery unit, it would 1, require another Avenger, 2, fly faster than the returning Avenger craft.
This idea also does present one more issue. What about early in the game BEFORE UFO Navigation is researched and understood? How do those UFO's return back to base. Probably just simply being towed under the skyranger if it is small... Or some other unknown process/technology. Perhaps when a UFO takes off with units inside it, if this were to happen early in the game, you will only be able to recover your men and the mission if you have UFO Navigation researched.