Easy. It's hard-coded to pick the facility that produces the max amount of a certain item. That's why you get level III facilities instead of level I in a normal SE4 High Tech game, for example.
You can test this yourself- make a new facility, no tech required. Now give it boatloads of mineral production- it'll be used instead of the default mineral miners. Give it boatloads of organics/rads/research and it'll be used in place of those. Give it resupply/spaceport, it *might* be used in place of those. etc
I don't think the homeworld type in the construction file does anything, other than maybe telling the AI not to scrap it's homeworld facilities for something "better"
Phoenix-D