In the U.S. there is a process informally called “burrowing in,” in which appointed posts are converted to career posts as a President is about to leave office. These would be lower level appointees, 3-4 layers down from the Secretary level. The idea is to leave behind embedded, ideologically motivated employees to continue the policies of the outgoing president, or mitigate the policies of the incoming one. I don’t think it’s especially common though, not least because these people can all make much more money in the private sector.
As for expertise, part of the process of “confirmation hearings” is theoretically to ascertain whether the appointee is competent to do the job; and most do bring relevant expertise. A Defense Secretary might be someone with long experience with armed service matters in Congress; the Agriculture Secretary is often a former governor of a farm state. Some upper-level appointees are people who have served in government in various lower-level capacities as political appointees and worked their way up. And some, even at high levels, are members of the out party who have relevant experience and are not known as partisan warriors.
There are some truly unqualified people who get their jobs–the best-known recent example was Michael Brown, the head of the Federal Emergency Management Administration during Hurricane Katrina, whose CV included a prior stint at the International Arabian Horse Association. I’m not picking on the W. Bush administration by the way, most of its appointees were serious, experienced people, whatever you think of their policies and job execution. You’ll find duds in any administration, especially among the ambassadors.