I think we may conclude that the Jeddah track - in spite of all the money and effort - simply lacked the requirements hosting a safe and smooth F1 Grand Prix as a result of a few rather basic design errors.
How can we prevent a farce like this?
1) Guidelines for homologations of tracks are formulated like this: https://www.fia.com/circuit-safety. Regarding safety these are nicely formulated from narrowly technical point of view, but they don't make much sense from a viewpoint of allowing a safe and fair race.
2) I Remember the times that before you could host a Grand Prix at a certain track you had to organise a tryout event, preferably F1. E.g. Jarama 1967 and the Argentinian and Brazilian GPs in the early 70s.
Since of course the Concorde Agreement you can't organise non-championship GPs anymore these days. But I guess a tryout event (or even the "threat" of a tryout event) in a decently competitive class or formula could have helped to iron out the most blatant design errors of this track.
How did we get into this mess?
The main reason is of course: greed. In a way an inevitable thing when it comes to a sport with almost stratospheric amounts of costs and as a result almost stratospheric needs of revenue. Still there should should have been a limiting power to this. It's the Commercial Rights Holder (Liberty) that makes the deals but FIA should have its say and use its power in regards to safety - in a way that precludes organise an F1 GP on a circuit that has not proven to have met a required level of safety. And a more strategically operating Drivers Association might help as well.