As above, I would suspect your brake fluid.
Brake fluid is hygroscopic - meaning it absorbs water - and this water lowers it's boiling point, brake systems aren't sealed to the outside air - so over time they absorb water - which is one reason your brake fluid needs changing every couple years.
If your brake fluid boils, it is turning from a liquid to a gas - so you lose the hydraulic brake force and your pedal goes down without the brakes doing much slowing down. As the fluid cools down - its turns back into a liquid and you regain your brake pedal.
This normally would never happen on the road, only happen gradually after some spirited driving/racing/ huge hill descent - to get some serious heat into your brake system. An experienced driver might feel their brake pedal getting a bit 'long' and back off the brakes to let them cool
On these two occasions when this happened to you - would you say you had used the brake a lot/down a big hill?
You could also have some brake binding issue - which is constantly applying the brake - with similar outcome - fluid boiling - made worse by old fluid.
After a drive walk around your car a feel your wheels - do any feel warm/hot?