Gasoline engines can be plenty reliable. I think the main reason why a lot of cars from the 80s and 90s are able to go to 400k and more is (1) cheaper and easier maintenance, so more inclined to do it regularly (2) no fancy shit going on, no turbo chargers, no high-pressure fuel injection, thus far less wear on parts, no unreliable high-pressure pumps etc.
Replacement parts on these are also far more expensive. New turbo is a four-figure number just for the part. Injection pumps are bloody expensive, too.
Less optimized designs may also be a factor. CAD and FEM modelling has only become better with time, so back in the day engineers would rather make a more conservative design, nowadays that's not so necessary any more.