Because society has been so determined to hide the truth about homosexuality, gay people start out in the closet, not accepting their homosexuality--often not even being able to comprehend the fact that they are gay. The lucky ones come out quickly. The unlucky stay in the closet all their lives.
There is a large gray area around the closet. Some gay people have gay sex and are either so shamed by it that they won't even acknowledge their homosexuality to themselves. Others use rationalization to hide from their homosexuality. Perhaps they don't consider themselves gay because they have families and only have gay sex on the side, or maybe they don't think they are really gay because they are always on top or because they have gay sex, but don't fit common stereotypes about gay people. Most closeted folks acknowledge their homosexuality or bisexuality at some level, but are unable to accept or even act on it.
Not knowing you are gay