What is the orbital refinery for?
It builds (automatically and free of charge) little freighters that fly to metal and crystal extractors, boosting their output and thus giving you a little extra resources. Check the metal and crystal numbers in the top right (hover over it for a bit) to see how much you get from it atm.
How can I get metal or crystal factories to mine them at a faster rate? (is it to do with orbital refinery)
Research the corresponding upgrades from the civilian research tree or build a refinery nearby.
i lost a planet to attack and the rest of my planets very quickly went down to allegiance 0 and i lost the game. did i need a broadcast centre to stop this?
Yes.
If it was your homeplanet, you have to set up a new homeplanet asap or all planets will lower allegiance to 25% (resp. 35% if it has culture). Also if the enemy has broadcast centers and you don't, quickly build up one of yourself or you'll lose allegiance pretty fast.