Bleed the brakes. Check for leaks.
It has air in the lines.
If it only happens when you have been driving for a while then it is water
(which boils from the heat and turns into a gas). Liquids cannot be
compressed, gasses can.
Either way you need to bleed them.
Empty out the brake fluid from the reservior and clean it with a rag, an old
t-shirt or something that will not leave any fluff behind, and fill back up
with clean fluid.
Crack the bleed nipple at the furthest point from the reservior, furthest in
terms of the longest brake line, and get someone to depress the brake pedal.
Close the nipple before allowing the person to release the pedal.
Repeat this 7 or 8 times and check the level in the reservior. Keep it
Keep pumping the old fluid through the first nipple until clen fluid comes
Repeat this for each of the nipples, going from furthest to nearest the
reservior, until each has clean fluid coming out of them.
Also, when was the last time you checked the brakes? Are the rear brakes
drums? Check the wheel cylinders for leakage by pulling back, with clean
hands, the rubber dust covers. If brake fluid comes out they are leaking and
need to be replaced.