Contradictory to the other posters here, I fully understand OP's ethical concerns. Although I'm all in favor of commercialization of research output, I witnessed the same behavior in my previous university and I'm not comfortable about it.
Although the difference between the study systems in Germany and the Anglo-Saxon countries have been discussed many times on this site, it's important to note that the Master degree in Germany is the 'undergraduate' degree, that students pay almost no tuition but are expected to fund their expenses by themselves (they rarely if ever get a stipend). Professors positions and laboratories are typically state-funded, that is with taxpayer money.
What bothers me most in OP's description is the systematic aspect of it. The main purpose of a Master project is for the student to develop a rather general set of skills (problem solving, creativity, critical thinking, thoroughness, etc.), and to be tested on the ability to achieve a research project, although modest in scope. It is not to write commercial-grade software in a state-sponsored trainee program for a Professor's spinoff company. Professors have a teaching and mentoring responsibility towards the Master students they supervise, and it's not waived by offering them a job when they graduate.
The other issue I see is the unsound hierarchical relationship. Master students are at the mercy of not getting their degrees if they do not perform according to the Professor's commercial requirements. This very often results in students being exploited.
I have seen professors use (state/university-funded) PhD students as free R&D, technical support and sales employees for their spinoff company, and I think it's dishonest towards the students, the funding agencies and the taxpayers. I even think it borderlines embezzlement of public funds, as the sole person really benefiting from the scheme is the owner of the spinoff.