One other thing that seems to be at least reasonably common among teachers is that, often, their salary is sort of secondary to their spouse's. I know a number of teachers who got into it both because they liked teaching, but also because they had kids and teaching allowed them to have a more similar schedule to their children while still earning a paycheck.
I have several relatives who are teachers, and most of them work during the summer at least some of the time. One of my aunts worked as a teacher at an educational summer camp, and I think one of my cousins mostly just teaches summer school for the school district. My aunt doesn't work during summers anymore, because she doesn't really need to (my uncle has always had a professional job that is their main source of income, and their children have grown up and moved out). I think she appreciates getting a couple months off that make it easier to take vacations and pursue her hobbies.
In the post-secondary world of teaching, a lot of professors have the option of getting their salary in either 9 months or 12, and there's always at least some summer school classes available that would generate additional pay. But for them, I think having summers off (even if it means their pay is lower) is actually a net benefit, because it gives them more time for research. Having a couple months of uninterrupted time means they are able to travel, if necessary, and focus entirely on their research and writing projects without having to take time out for preparing class materials or grading assignments.
But I think part of the answer with teaching is that, unfortunately, it's not a well-paid job. People do it because they think it's important and love it, and figure out how to make the budgeting work. It ought to be paid better than it is, since it is a professional job, it does require a bachelor's degree (at least) and certification, and it's a pretty difficult job to do well, but it often isn't.