Here is a solution that uses only basic Prolog: I think the base case should be the empty graph, not the graph with just one element. It has no nodes:
nodes([],[]).
For every non-empty graph, you collect the two nodes of the first edge, then continue with the rest of the graph:
nodes([edge(X,Y)|RestGraph],[X,Y|RestNodes]) :-
nodes(RestGraph,RestNodes).
The problem with this solution is that you have a node probably several times in the result. You can eliminate such duplicates with sort/2:
nodes2(Graph,Nodes) :- nodes(Graph,Unsorted), sort(Unsorted,Nodes).
CapelliC's solution is more elegant and concise, but maybe harder to understand for beginners.