To me there are both honorable and base reasons to take both jobs, and very few entrants are entirely on one side. These are both "vocational" jobs whose duties are their nature and which become a persona for their incumbents much more than jobs like, well..mine for a start. I deal in reports and spreadsheets and projects and decisions. If I and my cohorts do these things well, plants run effectively efficiently and smoothly; products flow into markets in appropriate quantities and quality, and companies both up and down the supply chain from my own share in our financial success. All good things, but while I might answer aa typical question "I am a Supply Chain Director", this is really not a quiddity or essence for me, but merely what is on reflection a rather odd but typical way of expressing how I earn money. "I am a soldier" or "I am a teacher" are much more reflective of a person's essential being I believe.
But why do people want to be soldiers or teachers? It's not that I grew up wanting to be in operations management, or that anybody did. It's not an aspirational job like they are even though it pays far more at least in discrete salary terms. That vocation speaks via the essence of the job to people who aspire to have it reflect on them. At the most elevated end of the reasons to be a soldier is the desire to earn the mantle of bravery, honor, sacrifice, guardianship and duty that the title entails. The same for teachers, who wish to embody the attributes of nurturing and molding future generations, of being a custodian and evangelist of knowledge and understanding. Somewhere beneath these aspirational reasons are the soft rewards you recount. Soldiers are respected and admired and given credit for our safety and freedom (regardless of how at risk they were or what the military has actually done lately to preserve them - it is the reflexive expectation of a reflexive and largely unexamined image). Teachers are, or as you rightly point out fast becoming WERE, honored as proxy parents with a greater ability to impart knowledge - often a greater knowledge period; as dedicated and respected guides through the challenges of childhood. But let's also remember that self-interest is never entirely absent even in the most devoted to these jobs. Both until very recently were known as nicely recession proof, with comfortable pensions and early retirements after careers half as long as those in private employment.
If soldiers were not thought of as heroes or teachers as respected professionals, you are doubtless right pay demands would increase - as they would if full pensions were only awarded after 40 years not 20, or if leave and holidays were the corporate norm too. The jobs grant a persona that some value -n yes indeed. But they are also jobs after all. A volunteer army that ran like a volunteer soup kitchen, with all work and only internal rewards, would be much smaller (not perhaps quite so small as would a volunteer operations staff be though!), as well as a terrible idea.
We run the risk of reducing the appeal of a military life if we parse the accolades given to soldiers too rigorously, just as I fear you are right that we are already reducing likewise the appeal of pedagogy. Surely though there is a sweet spot in between needless lionization and treating them like basic worker bees?