Wd40 can help stop squeaky brakes because it helps to lubricate the brakes surface along with the brake rotor and can help displace any water that may be on the brake pads or rotors which can be a cause of squeaky brakes.
If you just installed new brake pads then it could be the cause of the squeaky brakes as they have a metal fiber that eventually wears down and then the squeaky brakes stop.
If you haven't replaced the brakes then you could have a warped brake rotor or bad caliper not releasing which could lead to squeaky brakes.
If you've just installed new brakes or have had new brakes installed on your vehicle and they are squeaking it can be normal for new brakes to squeak for at least 500 miles or so.
New brakes have metal fibers in them usually which causes the brakes to squeak when rubbing against the brake rotors or brake drums when you're driving or pressing on the brake pedal to stop the vehicle.
Eventually this metal fiber will wear away enough to stop the squeaking of the brakes.
So if after 500 miles or so the brakes are still squeaking then have the brakes checked out because they may have installed the brakes wrong or installed too thick of brakes.
Your brake rotors could also be warped or your brake calipers may not be releasing the brakes far enough away from the brake rotors also.
You could try spraying some WD40 on the brake pads to help stop the squeaking or use some brake cleaner which also should clean off any debris and stop it from squeaking.
Almost all new brakes I've installed when Installed new brake pads they begin squeaking for at least 500 miles and sometimes as long as 1,000 miles and eventually as the brake pads wore down enough the squeaking stopped.