I'll go into a little more detail now that I'm at lunch.
Some departments have members who go through the "career service" (think non-political appointees) ranks and eventually hit those "secretary" level positions. I have a good friend who is very high in a very large department. That friend had a background in that industry.
I tend to think the folks who work their way through organizations get more respect (but not MUCH more) than appointees who came by way of campaign work.
Some leaders cross party lines. Secretary Bob Gates would be an example. The Coast Guard's old secretary, at Transportation, Secretary Norm Mineta, served Republican and Democrat Presidents.
You have SOME departments that require someone with a background in the industry.... you see it with the Treasury Department and often the Department of Agriculture.
And you'll have departments that are more of favors...
Now that top position "S-1" or "the Secretary"... those are often filled by an individual who was a big supporter of the president, in some way. A cabinet level position is a big reward.
Under that top spot are other "secretaries"..... first you have the Deputy Secretary, but after that it gets bumpy. The Department of Defense has some many different levels, under secretaries, assistant secretaries, deputy assistant secretaries, principal deputy assistant secretaries, etc.
Within the Department of Homeland Security it's not as complex, but here's an example of where some people came from.
Janet Napolitano was the governor of Arizona. She came from a boarder state, was supportive of Obama and fell in line with the "Administration." Napolitano's top leadership came with her from Arizona. Some of the old Arizona team was sprinkled throughout her leadership staff. Other members of DHS's leadership were campaign leaders. If you pick the winning team, and do enough to make them happy, you CAN be rewarded with a spot. Are you qualified for that spot? Eh, who cares?
A department job that seems "important" first.... isn't always important, and usually doesn't pay well.
That said, more often than not (and there are certainly many exceptions to this) you have to be politicially active, and your party has to win.
That's NOT easy (for a good number of reasons) for an active duty officer. It's SLIGHTLY easier for a reservist.
And I'll go ahead and tell you this, the vast majority of the people I worked with (and I'll include myself in this group), not only were not impressed with the Department of Homeland Security and it's leadership, we were usually disgusted with it. It regularly ranks at the very bottom of the "happy workplace" lists, and makes a habit of spreading the misery to the important component agencies.
When DHS was first created I bought the shirt and the pin and I said "yay, ra ra DHS". By 2011 I had ditched all of it (and it HAS gotten worse with this administration, folks will tell you behind closed doors).