Ok, that's not bad ... now you need to erase the first two rules, because they describe frontier inclusion of A in B (either B starts with A, or B ends with A).
And then you need to switch places between those 2 appends from the 3rd rule.
You see, for one append to work properly you need to take care which of the parameters you send in with values and which you send in without values (unbound).
append(A, B, C)
Case 1: A, B, C all have values - append will work properly and will return true if A + B = C and false otherwise
Case 2: A, B have values, C doesn't - append will return in C the result of A + B
Case 3: A, B don't have values, C has a value - append will return in A and B all combinations such that A + B = C
Case 4: A and C have values - append will return in B the list that satisfies A + B = C
Case 5: B and C have values - similar to case 4, append will return in A the list that satisfies A + B = C
You can try all these at the Prolog prompt. For example, to test case 3, type:
?- append(A, B, [1, 2, 3]).
and press ';' after each solution
Now in you case, your first append is something like this:
append(_, A, C) - only A has a value
You are in neither of the 5 cases presented above. What can Prolog do with these arguments? What would you do if I gave you a list A = [1, 2] and told you to compute two other lists such that X + A = Y ... infinite solutions, right?
Switch places between those 2 appends and you should be fine.