The problem with writing yourself, directly, as a character is that you come off as someone who wants to glorify themselves.
All writers put a bit of themselves in a character; their anger, greed, lust, altruism, ect. There's nothing at all wrong with this. Sometimes, actually, you need to do this in order to make your character seem all that much more real and believable. Channeling your own feelings of something through a character comes off much more naturally than forcing it.
Now, as stated above, some writers will insert themselves into a story, in whole, so that they can glorify themselves. "In this book, I do this!", "I did X in this book!", and so on. That, or they can't find it in themselves to construct a new protagonist, and would rather just insert themselves instead. This stems from a lack of creative thought in character design.
TL;DR: Every writer puts a piece of themselves in a character, no matter how large or small. The problem only arises when you supplement an entire character for a glamorization of yourself.