The issue here has to do with "undefined terms". Suppose that we are working with the field of real numbers (without non-real complex numbers). The signature for this field has symbols for addition and multiplication, the order relation $<$, and the equality sign.
This signature does not have a symbol for square roots. So the phrase "the square root of $-1$ is not equal to $1$" does not have any direct translation into the formal language at hand. If every number did have a unique square root, we could introduce a new function symbol $\sqrt{}$, and interpret it so that $\sqrt{x}$ is always a square root of $x$.
In contrast, every real number does have a square, so we could add a new unary function $S$ such that $S(x)$ gives $x\cdot x$. We cannot do that for square roots. In the field of real numbers, we cannot refer to $\sqrt{-1}$, as we have no symbol $\sqrt{}$.
We could translate the phrase "the square root of $-1$ is not equal to $1$" as "for all $x$, if $x^2 = -1$ then $x \not =1$". That new quoted statement can be directly translated to the language of fields, and it is true in the field of real numbers. On the other hand, the statement "the square root of $-1$ is not equal to $1$" can also be translated as "there is an $x$ with $x^2 = 1$ and $x \not = 1$". That statement is false in the field of real numbers. So the translation that we choose will affect the truth value.
In the general, an English sentence that talks about "the" object with a particular property makes an existential assumption that there is a unique object with that property. When that existential assumption is correct, it usually straightforward to translate the English sentence into a formal sentence, and the truth of the formal sentence will not depend on which reasonable translation we use. But, when the existential assumption is not satisfied, the exact translation that we use can make a difference.
Another approach to handling issues like real square roots (which don't always exist) is to introduce partial function symbols - function symbols that can be undefined on certain inputs. This is the subject of "free logic". But normal first-order logic is not a free logic: it assumes that a function symbol applied to an object always returns an object.
Yet another approach is to add a new function symbol $\sqrt{}$ and define it in some arbitrary way when it would not normally be defined. The, all we can say is that if $x$ has a square root then $\sqrt{x}$ is a square root of $x$. In that case, the statement "the square root of $-1$ is not equal to $1$" will depend on exactly how we arbitrarily assign values for numbers that don't have square roots.
Your teacher’s formula is correct except when $n=1$, which it says is prime (see the final section); for consistency with their terminology I shall use “prime” in this answer to mean “non-composite”. Your problem seems to be that you do not realise that $n$ is a “free variable” in formula (0), which we ought to call $P(n)$ to emphasise that it says something about $n$, some natural whose primality interests us.
A free variable (in a given formula) is one that is not a “bound variable”, where a bound variable is one introduced by a quantifier, in the way that $p$ and $q$ are. A free variable refers to something outside the formula, while a bound variable does not refer to anything outside the formula: replacing $q$ by $r$ would not affect the meaning of $P(n)$.
Where you write “Not for all natural $q$ and $p$ true, that, if $q*p$ gives us some $n$, then either $q$ or $p$ equals $1$.” it would be more accurate to say “…if $qp$ gives us the particular $n$ we are interested in, …”. That is to say, in your example we are only interested in the case $P(15)$, i.e. your (0) with $n$ replaced by $15$; as you correctly observed, $P(15)$ is false, so $15$ is not prime. If you try it out, you should find that $P(5)$ is true.
Your “gives us some $n$” makes me feel that you may be thinking of (0) as:
$$
(\forall q \in \mathbb N)(\forall p \in \mathbb N)(\exists n \in \mathbb N)[(n=pq) \Rightarrow (p=1 \lor q=1)]
$$
i.e. “every product of naturals is $1$ or prime” (or even “given two naturals, one is $1$”!), which is of course false. If you rearrange it as
$$
(\exists n \in \mathbb N)(\forall q \in \mathbb N)(\forall p \in \mathbb N)[(n=pq) \Rightarrow (p=1 \lor q=1)]
$$
it says “some natural is $1$ or prime”, which is trivially true. Both these formulæ have $n$ as a bound variable, i.e. they are not statements about a particular $n$ but about $\mathbb N$ as a whole.
In step (9) you write (with “complex” replaced by “composite”):
• For some $n$ its $q$ and $p$ are not equal one, then we know that $n$ consist of two numbers, then it is composite.
• For another $n$ either $q$ or $p$ can be $1$, then we don't know if n is prime or composite, cause another number ($q$ or $p$) can be either composite or prime.
The first part is more or less right, though “its $p$ and $q$” is a bit odd, as $p$ and $q$ are not determined by $n$, but are just some naturals that may need to be checked to see if $n$ is prime.
The second part is wrong: you are right that the case when either $p$ or $q$ is $1$ does not (on its own) settle the primality of $n$, but if all such $p$ and $q$ satisfy $ (n=pq) \Rightarrow (p=1 \lor q=1) $ that makes $P(n)$ true – that is what the universal quantifiers in $P(n)$ mean!
The case $n=1$
As pointed out the answer in the answer by Dan Brumleve, your teacher’s expression breaks down when $n=1$, though this seems to have nothing to do with your problems in understanding it.
Their expression $P(1)$ says
$$
(\forall q \in \mathbb N)(\forall p \in \mathbb N)[(1=pq) \Rightarrow (p=1 \lor q=1)]
$$
which is true: when the product of two naturals is $1$, then one of them is $1$ – indeed both are! But the conventional definition of a prime is that it should not be a “unit”, i.e. should not have a multiplicative inverse in $\mathbb N$. We can fix this by defining “$n$ is prime” as $n\neq 1 \land P(n)$. This is useful, as the primes are then the smallest set of naturals that generate $\mathbb N$ by multiplication. For $\mathbb Z$ there is no unique set of generators, but the sets are unique up to multiplying each element by one of the units $\{1,-1\}$.
Equally, their expression for “$1$ is not prime” becomes
$$
(\exists q \in \mathbb N)(\exists p \in \mathbb N)(p > 1 \land q > 1 \land 1=pq)
$$
which is false, again meaning that $1$ is prime.
Best Answer
A bit of intuition: Consider the formula $$∀x∀y((x ≠ y) → ∀z((z = x) ∨ (z = y)))$$
Note that it actually says
Then we see that the referred formula will be true in any interpretation which universe $U$ has two (or one too, by vacuity) elements. It will be false otherwise.
A bit of symbolism:
I'm afraid of being pedant, so don't read this if my symbolism may confuse you. First we recall the notions of interpretation of a First Order language. Given a language L, and a L-structure $M$, the domain of $M$ (we shall denote it by $|M|$) can be any set, as long it is non-empy and countable (so as an answer to your question, $\{0,1\}$ is clearly allowable).
Let $M$ be an interpretation such that $M \vDash ∀x∀y((x ≠ y) → ∀z((z = x) ∨ (z = y)))$.
This means that the formula is true in $M$. We state:
1. Let $|M|=1$. The formula is true, since $x ≠ y$ is false for every value of $x$ or $y$.
2. Let $|M|=2$. The formula is true, since $x ≠ y$ is true for every value of $x$ or $y$, but $∀z((z = x) ∨ (z = y)))$ is not false.
2. Let $|M|=k$, where $k\neq 1, k\neq 2$. The formula is false, since $x ≠ y$ is true for every value of $x$ or $y$, but obviously $∀z((z = x) ∨ (z = y)))$ is false (Pigeonhole principle).