Separate the two parts into
1) The bike failed mechanically or structurally.
2) I'm on a hill and travelling at speed.
So if your bike fails normally, there will be consequences which depend on the location, the failure, your reaction, and luck.
Taking the specific example of a flat tyre, we'll assume that its a sudden blowout or a tyre rolls off the rim completely. Both will cause your rim to run on the road surface immediately, and the rim has very little traction compared to an inflated tyre.
If the problem happens on the flat, you'll feel bump-bump-grind and you will stop with the brakes quickly. If you were turning gently, you'll probably recover after a fright. If you were turning hard, a front wheel blowout will cause you to suddenly lean even further, maybe beyond the limit and you're going down on the inside of the turn. If its your back wheel, then theres more chance of saving it, but there's also the risk of over-recovery and then you're falling off the outside of the turn.
Now, all that is bad enough, but if you're travelling fast, you have more kinetic energy (momentum)
A decent downhill speed could easily exceed 50 km/h (35 mph) and its not hard to hit 70. So the flat front while doing a hard turn will leave you with about 0 reaction time before your inside hip hits the road. Same goes for the other road users, the rider behind you who has to go left or right real quick, the car coming the other way who will intersect your path in under a second... do they brake? or cut left or right? Its all gone pear-shaped in less time than it takes to read a line of text.
In short, hills simply add speed to a situation. This multiplies the energy and enhances the risk.
Going UP a hill is no problem at all. A mechanical on a climb is generally easy to recover from.
The worst on a climb would be a chain break while standing to sprint. I've had this, and when putting foot down I couldn't reach the ground due to the profile of the road on that side. Cleats didn't help, so I gracelessly fell over, and the bike slid back down the road 10 metres or so. Again fortunately no cars were coming.
Another personal story - I had a wee fall at speed on a hill descent. It wasn't a bike failure, it was a loss of traction due to a lump in the road combined with white painted line and debris on the road.
I rolled across the wrong side of the road on my wheels, braking hard. Another metre of space and I might have held it, but instead rolled over the edge onto a steeply sloping weed area. So I chose to lean left and hit the ground nearer to me, rather than fall to the right and have further to fall.
Results - I stopped 3 metres off the road. When I stood I could not see the road and noone could see me. Noone saw me go, so I had to haul myself back up to the road. I was near enough to have a speaking conversation with someone, had there been anyone. a 10 minute sit down and damage assessment. Other than thousands of sticky weed seed pods all over me, I was merely winded. The road bike's wheels were still true, the only prob was the standard brifters pushed inwards. Nothing a quick yank couldn't fix. Then 20 minutes finding my gear which had spread itself down the slope. The only net damage was my helmet visor which broke off and vanished. This was my most major crash in 14,000 km of riding over the last 2 years.
Long term, I'm a LOT more cautious on downhills now. I will brake hard periodically to limit the top speed and alternate front and back to limit temperature increases in brakes. I don't lean into corners anywhere as much as I used to either.