it's a mixture of not particularly refined mineral oils and solvents once its solvents have evaporated off the oil will be hygroscopic and hold small amounts of water.
Why will the oil be hygroscopic? Without an emulsifier water and oil don't easily mix.
It's quite unbelievable how much crap is talked about WD40 (and other penetrating fluids) on the internet. It's effectively just a mixture of light petroleum distillates, as are virtually all penetrating fluids. Some have PTFE additives, some smell nicer but they all do very much the same thing.