Take $N < M$ two models of a first order theory. If $N$ is an elementary substructure of $M$ then any definable endomorphism must fix (not poitwise) $N$.
Does the converse hold?
Take $N < M$ two models of a first order theory. If $N$ is an elementary substructure of $M$ then any definable endomorphism must fix (not poitwise) $N$.
Does the converse hold?
The answer is no, for a rather trivial reason. The contrapositive of the statement you want to prove reads:
So for every non-elementary substructure, you want to find a definable endomorphism witnessing that it's not elementary. But many structures have no non-trivial definable endomorphisms at all!
For example, let $T$ be the theory of linear orders in the language $\{<\}$, take $M = (\mathbb{Q},<)$, and let $N$ be any sub-order which is not a DLO. Consider any endomorphism $f\colon M\to M$, definable with parameters $\overline{n}$ from $N$. Notice that $f$ is injective, since if $a < b$, then $f(a)<f(b)$, so $f(a)\neq f(b)$.
Now $M$ has trivial definable closure: for any finite set $A$, no element outside of $A$ is definable with parameters from $A$. In particular, for any $a$, $f(a)$ is definable from $a\overline{n}$. But if $f(a) = n_i$, then since $f$ is injective, $a$ is the unique element of $M$ satisfying $f(x) = n_i$, and this defines $a$ from $\overline{n}$. We conclude that either $f(a) = a$ or $a$ is in $\overline{n}$. That is, $f$ is the identity outside of $\overline{n}$. And since $\overline{n}$ is a finite tuple and $f$ is order-preserving, $f$ can't even non-trivially permute $\overline{n}$. So $f = \text{id}_M$.
So in this example, $N$ is trivially fixed by every $N$-definable endomorphism of $M$, despite not being an elementary substructure.
Of course, in this example already $M\not\equiv N$. You could strengthen your question, requiring $M$ and $N$ to both be models for the same complete theory $T$. Then to come up with a counterexample, we'll want to look at a complete theory $T$ with trivial definable closure which is not model complete (model completeness means that whenever $N$ and $M$ are models of $T$ and $N\subseteq M$, then $N\preceq M$, so the condition would be trivially satisfied).
But this isn't so hard to come up with, since there's a silly trick to take any theory at all and turn it into one with trivial definable closure: Add a new equivalence relation $E$ to the language, take a model $M$, replace each element of $M$ with an infinite equivalence class for $E$, and take the theory of the resulting structure.