Think about what is happening in the fuel supply system. With a mechanical pump the line from the pump all the way back to the tank is under a partial vacuum. It works fine until the EPA mandates a "gasoline" that has a lower temperature collective boiling point. Now that vacuum causes the fuel near any hot spot in the long supply line to boil. Presto, vapor lock. I forget the exact numbers, but some time ago I calculated the boiling temperature for some of the components in gasoline when under a partial vacuum, and it was quite easy for that temp to be as low as 90° Keep in mind that is the temperature of the fuel, not the ambient temp.
With an electric pump the fuel between the pump and the engine is under pressure, thereby raising the fuel's boiling point and making it harder for the fuel to boil and cause vapor lock. With the pump in the tank or close to it the length of supply plumbing is much shorter, and at least partially submerged in fuel.
For years people did all sorts of janky things, some effective, some flat out dangerous trying to head off fuel boiling AKA vapor lock when the simplest solution is to pressurize the fuel and raise it's boiling point high enough that it won't boil. Some very late carb'd vehicles use a by-passing fuel filter. Too little, too late, but they did mostly work even if the only line pressurized is from the pump to the filter.