In case of an electrical fire, disconnect the device from the main outlet to cut out the power source if it’s safe to do so. Try putting out the fire using a fire extinguisher. Don’t use water or foam fire extinguishers to put out electrical fires as both can act as a conductor of electricity.
If the material that caught fire is wood, paper, cloth, trash or plastic, then you can use a foam extinguisher or water to put out the fire. These will cut the heat supply to the materials.
For materials like alcohol, petroleum, gasoline, and paint, you have to use foam, powder, or carbon-dioxide extinguishers. These are known to cut the oxygen supply to the fire and put it out.
It is best to leave further investigation and remediation to expert fire damage restoration services.