Let's start with the fact that bouyancy of an object in open water is caused by displacement, but liquids that are less dense and may spread out do not displace water, they just lie on top of it. If I put a block of wood in a fish tank that is full, it displaces and spill over a mass of water equal to the mass of the block, but if I slowly pour (or rather spray) oil on a full tank of water, the oil will spill over, not the water. The definition for displacement is (per Google):
- the moving of something from its place or position.
- the occupation by a submerged body or part of a body of a volume that would otherwise be occupied by a fluid.
The first definition is what WD-40 is doing to water, the second one is what causes buoyancy. The WD-40 displaces the water in that it moves it from where it is, but how?
Looking at the ingredients from the SDS, we can get a feel for their purpose:
$$\begin{array}{|c|c|c|}
\hline
\textbf{Material} & \textbf{Hazards} & \textbf{Purpose (not stated on SDS)}\\
\hline\text{Aliphatic Hydrocarbon} & \text{Flammable Liquid Category 3} & \text{Thin oils and evaporate quickly}\\
& \text{Aspiration Toxicity Category 1} & \text{}\\ \hline
\text{Petroleum Base Oil} & \text{Not Hazardous} & \text{Provide long term protection} \\ & & \text{from water and air}\\ \hline
\text{LVP Aliphatic Hydrocarbon} & \text{Aspiration Toxicity Category 1} & \text{thin oil and evaporate slowly}\\ \hline
& \text{Simple Asphyxiant}\\
\text{Carbon Dioxide} & \text{Gas Under Pressure,} & \text{Propellant}\\
& \text{Compressed Gas}\\ \hline
\text{Non-Hazardous Ingredients }&\text{Not Hazardous} & \text{This does the real work}\\ \hline
\end{array}$$
The oils are nice because once the water is removed, the oil will remain, preventing it from returning. But it is the non-hazardous ingredients that do most of the work. Hard to say what exactly this 10% is made of but it has to get water to "unstick"/"unwet" the surface that is being treated. To do this WD-40 is likely using a non-ionic surfactant of some sort similar to what is used in shampoos to emulsify the water and allow the flow of the WD-40 spray to remove (displace) the emulsified water. $%The rest of the wD-40 components act as carrying agents to remove the water from whie$ This speculation about surfactants is further supported by the fact that WD-40 foams when sprayed which is not characteristic of pure hydrocarbons.
Additionally, there would likely be some material to adhere to the surface to prevent further interaction with water or oxygen. There is the petroleum base oil, but it needs a way to stick to the metal. Likely, the use an unsaturated fatty acid in some way whether it is pure oleic acid or boiled linseed oil or something similar to those to bond to most metals and other materials and prevent further corrosion.