Never use "I'm John Smith" when you introduce yourself; instead, use "My name is John Smith."
I would agree with this much: in general, using "my name is" is probably preferable to "I am", because there is more to who we are than our name.
That said, I think never use is a bit overly strong, although I wouldn't be surprised to learn a non-native-speaking English teacher was offering that advice. Language teachers can sometimes be a bit stuffy, and woefully unaware of oft-used, informal conventions.
Most native speakers aren't going to bat an eye if you say, "Hello, I'm David." It's normal, idiomatic conversational speech.
Moreover, there are times where "Hello, I'm David," might be the most natural way to say your name.
Suppose you are one of four people are seated in a circle in a classroom. Your name is John Smith. The teacher asks you all to introduce yourselves to one another, and the person to your left begins:
"Hi, I'm David Carson."
and then it continues clockwise around the circle:
"Mike Jones" [uttered with a quick wave]
"Hello." [smiles and nods] "Linda Everett."
Now it's your turn. Follow the advice of your English teacher, and you'll mechanically say,
"My name is John Smith."
Truth is, "I'm John Smith" would have been just fine. Most likely, no one is going to think David Carson is an idiot who does not know the right way to introduce himself.
As I write this answer, I'm imagining myself in different settings, giving my name for the first time.
I think tone can be as important as word choice. Give your name as if you're God's gift to the world, and it can sound either mechanical or pretentious.
Context is also important. "I am..." sounds natural if you are giving your name plus some additional information:
I am David Carson, the marketing director for Acme Corporation.
which is a nicely condensed form of:
My name is David Carson, and I am the marketing director for Acme Corporation.
Lastly, conspicuously absent from your question is the difference between "I am David Carson," and "I'm David Carson." The contracted version can sound more approachable and friendly, while the longer version can sound more stiff and pretentious. That said, mannerisms such as warm smiles, friendly nods, affable handshakes, and welcoming intonations also play a big role in how your introduction will be perceived.
If you're too worried about the words you use, that might have an adverse affect. Just relax and tell us who you are.