Use of "Who am I" and "Who I am?"
Solution 1:
Sitting at the end of the stairs, sobbing, having lost my love, career and self-respect, I say to myself, "Who AM I? What is the purpose of my life?" See, here it is a question. That's why the helping verb (am) is coming before the subject (I).
I ask myself who I am. Here, it is not a question, a mere narration of what I ask myself. So, it is not ending in question mark, plus, helping verb is after the subject.