AMBoy's link in AMBoy's second post is a great link. I would give it five likes it I could. Again, this link specifically:
learningtagalog.com/ grammar/enclitic_wor ds/using_enclitic_wo rds/order_of_en
Anyway, the reason why there's the difference between "Mahal ko siya" (verb + ng pronoun + ang pronoun) vs "Mahal ka niya" (verb + ang pronoun + ng pronoun) is because the order of the pronouns is because there's a specific order for these pronouns to go in generally.
You'll notice that in the table from the link above, the following is the order of the pronouns:
1. All the two letter pronouns (i.e. ka, ko, and mo)
2. Then, the "ng" verbs (i.e. niya, nila, namin, natin, ninyo)
3. Then the "ang" verbs (i.e. ako, siya, kami, tayo, kayo, sila).
In other words, for this specific example which is object-focus, the order is generally "verb + ng pronoun + ang pronoun", except when:
a) when "ka" is used (e.g. mahal ka namin)
b) the two pronouns are "ko" and "ka" (in such a case, "kita" is used instead - e.g. mahal kita)
I wouldn't be surprised if there are exceptions to this rule regarding pronoun order, so if they are please let us know!
EDIT: The order of words and pronouns can get more complicated when you add things like "hindi",
"pala" and "po" in your sentences, but I think what I've said satisfies your question. Please let us know if you have any more questions.