It's partly because guys believe girls experience attraction in the same way they do. They reason that, if they don't have the physical features girls find attractive, they must be unattractive.
It's also partly because if you have a negative self-image you can become a self-fulfilling prophecy. If you think you're unattractive you don't exactly exude masculinity and confidence and of course women don't even notice you which reinforces the belief that your unattractive and the whole cycle perpetuates itself.
Well I can only speak for myself but growing up you always get so much negativity and mean spirited comments from everyone, particularly during school. Women get told they are beautiful, whereas complimenting men isn't the norm. So it takes long time to appreciate yourself and build up your confidence. I remember it took me til I was like 20 before I started to appreciate how good I looked. This is despite receiving a LOT of female attention in high school. Maybe your fellow too has received nasty comments?
I actually find it is usually girls who do this. Or maybe guys do it equally, just aren't as vocal about it? But either way, I wouldn't say that guys "always do this". But I think the reason, with anyone doing this, is just insecurity.