My (reputable!) dictionary gives the fanny = backside meaning as a twentieth-century one; but I'm suspicious - what about that dirty 18th-century novel,
Fanny Hill? The author left no stone unturned or mons veneris unclimbed in his quest for a snigger! Probably the 20th century was when respectable people started admitting they knew the secret meaning!
As for where the secret meaning came from, it's anybody's guess, though my guess would be that it started off as an item of gay slang. Sort of like
Nancy.
Incidentally, fanny in British English doesn't mean backside - more like front side - and it was startling to see
Denis the Menace's mother in one cartoon strip telling
Denis to get his wet fanny into the bathroom. All he'd done was stay out in the rain ...