Because it has nothing to do with his profession.
So I was eating pizza with my Classical Language teacher, talking about everyday things like Aristotelean logic and Venerable Bede. And suddenly, out of the blue he asks "Are you going to convert to Orthodox Christianity?" That was unexpected.
Is he Orthodox? Even then, that's kinda unprofessional for a teacher to inquire about the religion of his students.
That seems a bit rigid to me. Can teachers and students never form friendships? I agree that one has to be careful, but I've had close friendships with many of my teachers, and I talked about my spiritual struggles with my PhD supervisor. People are not robots with neat mental compartments called "professional" and "personal"; your personal life does have an effect on your professional life.
For example, if you are going through personal troubles, for example, that can impinge on professional performance, and I would admire a supervisor who took that into account when evaluating your performance, rather than use it as a pretext to fire you.
I think what would be unprofessional is if your teacher went on to use your choice of religion to give you better or worse grades, regardless of how you performed in the subject. But taking a friendly interest is not a problem, IMHO.