count([H|T], X, N):- count(T, X, N1), X=:=H, N is N1 + 1.
here you state that N must be N1 + 1 if X is H; however, you are not determining what should happen if X is not H (basically the else clause is missing) this should work:
count([H|T], X, N):- count(T, X, N1), (X=:=H-> N is N1 + 1 ; N is N1).
another way:
count([H|T], X, N):- count(T, X, N1), X=:=H, N is N1 + 1. count([H|T], X, N):- X=\=H, count(T, X, N1), N is N1.
but this is inefficient, since count (T, X, N1) will be called twice if X is not H. We can fix this by doing a check in the sentence header:
count([H|T], H, N):- count(T, X, N1), N is N1 + 1. count([H|T], X, N):- count(T, X, N1), N is N1.
or simply: count ([H | T], H, N): - the number (T, X, N1), N is equal to N1 + 1.
count([H|T], X, N1):- X=\=H, count(T, X, N1).