Fingerprints are formed based on random genetic mutations, as the fetus develops in the womb. Fingerprints are formed and become permanent by the time a fetus is 6 months old, that is 3 months even before they are born. They are formed on the palmar surface of the hands and feet and these patterns are unique for every human being.
Fingerprints once formed are set in stone, by the time the fetus reaches 17 weeks. The ridges are formed due to fluctuations in the hormone levels and the pressure faced by the fetus in the womb and even the length of the umbilical cord also matters in the formation of fingerprints.
That is the reason why even identical twins have different fingerprints.