As implied in one of the comments, context matters.
A permutation matrix is an endomorphism when acting on the set of all orderings of a finite collection of items. But for example, the permutation $S_{213}$ that swaps the first and second element of an ordered $n$-tuple is not an endomorphisim acting on the set
$\{(1,2,3), (2,3,1), (3,1,2)\}$.
Your second example, where you have specified the set $A$, is indeed always an endomorphism. It works on every element of the set $A$, and everything it can transform an element into is indeed an element of $A$.