In my experience, with about thirty years behind the keyboard, programming is a talent. It requires both the ability to think logically and the ability to think systemically. There's perhaps five percent of the population that are naturally wired that way, and perhaps another 15-20 percent that can learn enough patterns to to fake it. The good ones also tend to be autodydactic. You can tell the naturals even in grade school - they're the ones who've figured out all the cheats to their favorite games and use those cheats to manipulate the games never intended by the games' creators (I have one daughter like this, the other should never be allowed near a command line). The naturals gravitate to programming because it's what they do - the remainder are in it because of the salaries and other perks that come with it, and most of those eventually end up in technical management.
What this means is that programming professions generally follows the trade/mentorship route (there's actually a lot more similarity between being a plumber and being a programmer than most programmers are comfortable with). You can learn "how to program" in school, but most of the good programmers I've worked with over the years tended to have one or more mentors at some point in their career that steered them in certain directions, that helped them smooth their rough edges and that ushered them into a particular programming "school" or community. Apprentice, journeyman, master. Those mentors also periodically put challenges in the way of their apprentices, because programming is, at its core, the application of "magic" in order to solve problems, and if a person cannot work their way through a relatively benign problem, what's going to happen when they reach a real world one that is far from benign.
Most politicians are not inherently logical problem solvers - they're salesmen. They attempt to get their agendas passed by selling the idea, by making deals, by trading, none of which can be readily quantified programmatically. They see IT jobs as "green jobs" - low environmental impact, high salary, and in theory trainable (those holds true for most STEM jobs for that matter).
In practice, both the intrinsic aptitude requirement and the 10K hour rule still apply, and as you point out, there are a lot of half-assed "programmers" out there who will be able to solve problems through the application of automated problem solvers but who have only a marginally understanding of the fundamentals of computing.