There appear to be a couple of competing theories for why this happened.
The first is essentially phonetic: the forms where a 'genitive' is used are the ones where genitive and oblique forms differ in a single vowel ("thou" vs "thy", "me" vs "my" etc, compared to "him" vs "his" where there's also a consnant change). As I understand, the main problem with this theory is that if it was true, you might expect to see a period of variation between "genitive" vs "oblique" forms across the board, including e.g. "himself" vs "hisself". There's a small amount of evidence for this (e.g. different manuscripts of the same text where forms such as "himself"~"hisself" alternate in what is otherwise the same sentence). But maybe not as much evidence as you'd expect.
The alternative theory is syntactic and a bit more complex but essentially has to do with a statistical split that already existed in Old English. In Old English, "self" was essentially an adjective that served as an intensifier, a bit like "own", "very", "per se" in English today. Old English didn't have "reflexives" as such: "I saw me" was the way to say "I saw myelf" (as it is in German, French etc today); "I saw me self", would be a particularly emphatic version, a bit like saying "I saw my very self" in Modern English. Now, the interesting thing to note at this stage is that (a) as an adjective, "self" was case-marked as usual, and was of the same case as the word it accompanied; (b) as an adjective, "self" was readily used with any noun and so was probably more common in the third person at that stage. Or put another way, in Old English, saying "thou self" was a bit like saying something like "you your very self" today: it was an emphatic phrase that would occasionally be inserted, but wasn't so common compared to in the third person.
As Old English gradually lost its case system, there was then a grammatical "re-shifting" or re-interpretation that took place. One important change was that "self" gradually changed from an adjective into a noun, probably driven by the loss of case endings (a word used as a general intensifier in lots of places is arguably more recognisable as an adjective if it has case endings).
As that occurred, the third person cases of "him self" etc where then more clearly marked as "objects" because they also frequently occurred in parallel to other cases of "self" still as an intensifier alongside other nouns/noun phrases (i.e. people still said "I saw him self", but also "I saw the butcher self", so they had it 'more in their minds' that "self" in these third person cases was used alongside an 'object'). So there wasn't so much impetus to evolve "him self" > "his self" (though there are a few instances of evidence for "himself" ~ "hisself" existing as alternatives in Middle English).
In the other persons, on the other hand, a phrase like "I/me self" tended to be used in a sentence as an emphatic "incise" or interpolated phrase rather than the subject/object per se-- a bit like saying nowadays "I myself, I believe that...". So in these cases, with "self" as a noun, there was more of an impetus for "I/me self" to evolve to "my self" to help allow the noun "self" to 'have somewhere to go to' grammatically: "my self" now becomes a more cohesive unit. It's worth noting that the third person forms "himself" etc fused together earlier than "my self" etc, which continued to be written as two words for some time.
Further reading (on which the above draws):
- Van Gelderen (2000), "A History of English Reflexive Pronouns: Person, Self, and Interpretability."
- Danijela (2003), Review of the above book in The Canadian Journal of Linguistics (which helps to summarise some of the main arguments)
- Sinar, B., (2006), "A History of English Reexives: from Old English into Early Modern English" (a PhD thesis that doesn't focus exclusively on this issue, but mentions it in passing with some examples of some of the forms/phenomena I've mentioned above)