It works something like the following. The boss of someone ineffective makes clear to them they have no promotional future in the agency where they currently work, but might have in another government agency.
Then a letter of recommendation is drafted, curated, and polished that makes the ineffective individual look good "on paper" while not actually lying. The goal is to get rid of the turkey and if s/he gets a promotion in the process, it is no skin off the current boss's nose.
If the new agency is lazy and doesn't do their due diligence, they can get stuck with a real loser. It happened to the agency I worked with when we hired a new director of public information (public relations by another name) who had held a similar position for a smaller agency where the job paid less.
After we'd had the new guy long enough to know he was an empty suit, we met some employees of his former, smaller agency who said they couldn't believe we'd hire such a jerk. Needless to say they considered his move to our agency a real plus for their shop.
Why do federal managers engage in such chicanery? Because firing a loser is too difficult and uncertain, thus ultimately not worth the grief and actual risk to one's own career.