I think that people do it for a whole bunch of different reasons. Helping others is one of them, yours is another. But I remember that back at the start of code-sharing, the usual reason people gave for doing it was to help advance overall knowledge.