Hands up all those who remember when the full name of WD-40 was Rocket WD-40.
WD-40 is a water-displacement spray. It was the 40th attempt at a formulation to displace water from rockets awaiting launch, and thus prevent pools of standing water and hinder corrosion. It was developed in 1953 by Norm Larsen for the San Diego Rocket Company.
It’s primary constituent is a heavy, sticky, viscous oil. To help WD-40 get to where it’s needed this oil is diluted with lighter hydrocarbons which quickly evapourate.
The point is that WD-40 is excellent for displacing water and keeping it displaced and it’s excellent at penetrating. What it’s not good at is lubricating.
If you have a lock that not working smoothly, do not use WD-40. You are effectively squirting glue in there. And you are washing away any grease that the manufacturer put in there (although well-designed and well-made locks, like Chubbs, for example, don’t need lubricant.) Use a silicone spray or a teflon (PTFE) spray, or better still some graphite. If you can’t find graphite but you can find a soft (2B, 3B) pencil, scrape some graphite off that. Graphite is slippery because its carbon atoms are in flat sheets that slide over each other. And it will remain slippery forever for all practical purposes.