If A->BCDE and B->A then A->B->A. Therefore A and B are both candidate keys of R.
Suppose you have a relation R and a set of dependencies F. If you must infer the keys of R only from what is in F then any attribute of R that doesn't appear on the RHS of any dependency in F must be a prime attribute (i.e. part of a candidate key). I expect that is what your teacher meant. That doesn't mean that prime attributes may never appear on the RHS. They may do if there are multiple candidate keys.