Because they like what they do and sharing knowledge helps you learn and network. Go on youtube and look for tons of drawing tutorials, music creation, sculpting, etc. pretty much anything creative and accessible will have people who will give away knowledge for free, sharing what they discovered or w/e.
There's also selection bias, programmers create digital content so it's bound to be over-represented on the internet.
Many of my hardest problems involve people in decision-making positions that don't have any idea about how computers or programs work. Getting the rest of the world to be more conversant in programming will allow for more meaningful work. For example, we know what an EKG and an APB are, but people don't know what a compiler is.
In the view of those promoting programming education it is a skill that everyone should have the opportunity to learn -- more akin to reading or writing than specialized skills like making glue or regulated subjects like law.
There is also a lot of room for creativity in programming, which means it probably has a higher chance of being adopted just for fun.
I can't imagine any other industry doing this. I don't go on to the website of 3M, for example, and see stuff teaching me how to make my own glue. When I speak to a lawyer they don't try to teach me how to be a lawyer. Why do so many programmers feel the need to do this?