You shouldn't use families for spawning like that. what you can do is:
local number UID = 0
decide to spawn catapult / melee
create catapult / soldier
set UID to catapult / melee.UID
then pick friendly with variable UID
set isFriendly to differentiate between Friendly Unit and Enemy unit
treat both objects the same...
when you create a catapult, it will automatically be a member of BOTH families (all families that you assigned it to), so you can pick either friendly or enemy with UID
Also: the Familiies dont help to differentiate between enemy/friend if both objects are in both families.