How to avoid too hot pan that causes fire
Not likely that pan itself was hot enough to ignite. The auto-ignition point for cooking oils is 400 to 435°C (750 to 815°F).

You must have splashed some oil and it contacted an ignition source (e.g. flame).

One option would be to kill all flames before adding any oil.  Note that on an electric stove, it'll take some time for it to cool down, so you'd have to kill it and wait.

Have a proper lid on hand to smother a fire. 

A deeper pan will help.  

Pour only what you need from a measuring cup.

Most important - stop cooking so hot.  The oil will splatter more, the oil will be more volatile/flammable, and you have a bigger ignition source.

How Hot Does Cooking Oil Need to Be Before It Catches Fire?