What do you mean by "mostly"?
So side that is committing a takeover can still be set as attacker? - If it is so, are there specific circumstances when the side which is committing a takeover will be set as attacker and when as defender or it is purely random?
No; by "mostly" I only mean that there are a couple of minor differences in the order of how allies are calculated between the region owner and a realm running a takeover on the region.
When and whether they themselves will be defender acts exactly the same as if they were the region owner, so long as the takeover remains active.