Your friend was advising you not warning (meaning 1) you.
"If you don't stop smoking, you'll die soon." That's a warning.
Rewrite this sentence:
1. My friend told me, If I were you, I would not smoke so much.
A. My friend advised me not to smoke so much.
B. My friend warned me against smoking so much.
The key said A is the answer but I don't get why I couldn't use B. Some explanation please
This seems like a poor question. Depending on context and tone, you could consider it a warning.
In my opinion, she actually did neither. She simply stated a fact - that she would not smoke if she were me. If one has to be chosen, though, I would say it's advice rather than a warning.