You need to make your proposals mutually exclusive; the second sentence will be executed wherever the first one is.
As for your mistake, we are talking about the flow of information. You need to exchange the lines in the first sentence like this:
rate(X,[H|T],N):- X == H, rate(X,T,N1), N is N1+1.
This change will make your predicate non-recursive. To be recursive, it must transmit information through the call chain, and not receive it back on the way up, as it is now:
rate(X,[H|T],N):- X == H, N1 is N+1, rate(X,T,N1).
Now you see that here you have not received the final value, but indicate the initial value. When we reach the base case, we get our result:
rate(X, [], N).
here N is the result. How to return it? Use an additional argument, an indispensable variable that will be combined with this result when we reach the bottom:
rate(X, [], N, V) :- V is N.
Now the recursive clause should match this variable, passing it unchanged along the call chain.