We use this to mean 'I'm surprised to see you here.' and/or 'I didn't expect to see you here.'
The expression uses the older meaning of the verb 'fancy', which is to 'imagine'. If you say 'Well, fancy that!' it means 'What a surprise. It would never have imagined such a thing'.
By the way, we often use 'Fancy seeing you here' in a sarcastic fashion, if two people meet in a place where they have often bumped into each other before - suggesting that it isn't a surprise at all.