some guys, like a lot of girls, make up a significant other if they thank that will make a girl more likely to talk to him, initially, because she will relax and not worry about his intentions. But they will tell a girl that he is single if he's already decided to make a play for her. Devious, no? So many girls have phantom boyfriends to scare guys away they don't particularly fancy...
I really doubt he has a girl friend if he's telling contradictory stories about his status.
Guys can do this. Some will say "what a loser to do such a thing". It kind of is loserly indeed.
Telling a lie like this can back fire for the guy. I would not do that. Some guys also do this to look cool in front of a girl. They feel they may impress their peers or appear mature or something. But when the lie is caught, its shame on the guy.
If a guy tells that he's taken, then that means he doesn't like her, and have no intention of approaching her or accepting her as a girlfriend. He just doesn't want to hurt her feelings because men know that a lot of women have a very hard time handling rejections.