It can happen with other words too. There is no single common rule, unfortunately. Instead there are numerous types of situations in which you pick genitive or accusative.
Your first sentence "Я не люблю этого" falls into Category 1 of Genitive outlined below.
The object should be in Genitive if:
1) it is a pronoun.
E.g. Я не люблю этого.
Я этого не понимаю.
The rest of the explanation may be excessive for your particular case but I leave it just in case.
2) it follows a verb conveying feelings or attitudes (implying emotions)
E.g. Я не чувствую страха. Они не замечают времени. Ты не боишься опасностей.
3) it follows the verbs "не иметь" and "не хватать" and the word "нет" (= not have sth / there's no.../ lack sth).
E.g. Это не имеет значения. У меня нет времени. Ему не хватает терпения.
4) it follows negative particles (ни) or negative pronouns (ни один, никакой, ни единого)
E.g. Нет ни минуты покоя, не терять ни единой минуты, не было ни одного раза.
It is really tricky.