All of these ships have a breathable atmosphere inside of them, as well as flammable materials. If oxygen is leaking because of a hull breach, it can burn.
It's also a common misconception that there is no fire in space. We already have flamethrowers that work in a vacuum, because their fuel includes an oxidizer. There are also plenty of materials and things that may burn without external oxygen supply for that exact reason. It's possible, and likely, that the ships are leaking such liquids or gases, which catches fire when in contact with a heated hole in the hull.
Also, the short bursts of "fire" might be leftovers from turbolaser shots - which aren't really lasers, but superheated Tibanna Gas, basically plasma - and not oxygen-fueled fire at all.
That said, rule of cool and lack of scientific knowledge is the most likely cause of those fires, and not actual physics.
user151841 also raises a very valid point - the flames serve to tell the viewer just how extensively damaged those ships are. We, as Earth-stuck people, are used to the idea that damaged vehicles (or other constructs) catch fire when heavily damaged.