Just from what I've read elsewhere (not claiming any deep expertise in this area at all!), gender identity and gender sexual attraction seem to be largely set by birth, but from what I understand 'they' think that most kinks take root in the 2-4 year old age range. Apparently there are higher levels of sexual hormones at that age and we kind of map out in more detail what is to be desirable to us. But that is before the age where we retain much conscious memory, so by the time we remember our thoughts and feelings we just know that "we've always been that way." I suspect that there is more to it than that, that there may be a genetic or in utero component that guides that development a bit more, but that is just my guess.
It's more difficult to pin down what causes sexual preferences other than sexual orientation. I have a feeling that many "kinks" will be described as "preferences", when it is found how many people have them. I'm talking about changes in the English language (semantic shift) here. But here's a funny story.
My dad was a fat man and we had many other fat men amongst our family and friends. By the time that I was 4 years old, I thought that fat men were wonderful. I wanted to be a fat man, when I grew up. I started to pad, because I wanted so much to be a fat man. We had a friend, whom I was encouraged to call Uncle Roy, even though he wasn't related to us. I thought that Uncle Roy was wonderful and I wanted to be a big fat man just like him. I noticed that my dad and the other men called Uncle Roy Fatty. At 4 years of age, I lacked the maturity to observe that they only called him Fatty behind his back and never to his face.
One Sunday morning, my father was reading the newspaper in the living room, my mother had gone out and I was playing in the kitchen. Uncle Roy appeared at the back door. The kitchen door was open and the porch door had one large glass panel. Uncle Roy open the porch door and stepped inside.
"'Ey up, dad, Fatty's here!" I yelled with delight.
My dad came into the kitchen to say hello to Uncle Roy, who was very upset about being called Fatty.
"If a lad of mine said that, I'd give 'im a scuft round the ear," said Uncle Roy.
My dad tried to dismiss the matter as a childish triviality.
In the moment my world fell apart. I realized that other people didn't view be fat as the positive, beautiful and desirable thing that my four-year-old mind did. I realized that most fat people were ashamed of being fat. I had to keep my desire to be a fat man and my padding as dark secrets, until I discovered Dimensions.