"What is the teacher's last name?"
First, I am a beginning Mandarin student, so please do not accept my answer as authoritative. However, it is my understanding that 吗 is used to turn a statement into a question, but it has to be a yes/no type of a question. For example, you could turn the statement, "The teacher's last name is Li (老师姓李)" into "Is the teacher's last name Li? (老师姓李吗？)“ with just the 吗 particle. However, for other types of questions you need other types of constructions. 什么 ("shén me") is a question word that means "what" so it is used for many open-ended questions. Also, as you may notice, they aren't phonetically identical. 吗 is "ma" and 么 is "me." Close, but not exactly the same. Hope that helps.