I understood that the original Humpty Dumpty was a primitive cannon, which makes the rhyme more understandable, but not exactly sexual.
You can see a song in the Bodleian Library called 'The Beautiful Muff' which was obviously full of double meanings. This use of the word goes back a long way.