A subgroup which is generated by $W$-marginal subgroups is itself $W$-marginal There is a conclusion on $W$-marginal subgroups of a group:

A subgroup which is generated by $W$-marginal subgroups is itself $W$-marginal.

Here, $W$ is a set of words. In a group $G$, a normal subgroup $N$ is $W$-marginal in $G$ if $w(g_1, \cdots, g_{i-1}, g_ia, g_{i+1}, \cdots, g_r) = w(g_1, \cdots, g_{i-1}, g_i, g_{i+1}, \cdots, g_r)$ for all $g_i \in G$, $a \in N$ and all words $w(x_1,x_2, \cdots, x_r)$ in $W$. This is equivalent to the requirement: $g_i \equiv h_i$ mod $N$ $(1 \leq i \leq r)$, always implies that $w(g_1, \cdots, g_r)=w(h_1, \cdots, h_r)$.
But if I

Let $W= \{ x^2 \}$, $G=D_4$ (or sometimes denoted $D_8$), the dihedral group of order $8$. $G$ can be written as $$\langle a,b\mid a^2=b^4=1,abab=1\rangle= \{1, b, b^2, b^3, a, ab,ab^2, ab^3\}.$$ Let $N_1=\{ 1, a, b^2, ab^2 \}$, $N_2=\{ 1, ab, b^2, ab^3 \}$. Then $N_1 \trianglelefteq G$, $N_2 \trianglelefteq G$. Moreover, since both $N_1$ and $N_2$ consist of elements of order $1$ or $2$, $N_1$ and $N_2$ are $W$-marginal subgroups of $G$. $N_1$ and $N_2$ generate $G$, but $G$ is not $W$-marginal, as $b\in G$ and $b^2 \neq 1$.

This contradicts with the conclusion.
I am eager to know where is wrong, and why the conclusion is all right. Thank you very much!
(Page 62, Derek J.S. Robinson, A Course in the Theory of Groups, GTM 80)
 A: Note that usually we define the (full) marginal subgroup by requiring that insertion of $a$, on either side, not affect the value of the word. This does not require the assumption that the subgroup be normal ahead of time. With the added assumption that your elements form a normal subgroup, this is equivalent, of course, since $Ng = gN$ as sets.
Theorem. Let $G$ be a group. The full marginal subgroup associated to $w=x^2$ is the set of central elements of exponent $2$; i.e., $w^*(G) = \{ g\in Z(G) \mid g^2 = 1\}$.
Proof. Let $g\in Z(G)$ be of exponent $2$. Then for all $x\in G$, $w(xg) = (xg)^2 = x^2g^2 = x^2$ (since $g$ is central and of exponent $2$), and likewise $w(gx) = (gx)^2 = g^2x^2 = x^2$. Thus, $g\in w^*(G)$.
Conversely, let $g\in w^*(G)$. Then $1 = w(1) = w(1g) = g^2$, so $g$ is of exponent $2$. Now let $x\in G$. Then  we have that $w(gx) = w(x) = w(xg)$, hence $gxgx = x^2$. Thus, $gxg = x$, so $gx = xg^{-1} = xg$. Thus, $g$ centralizes $x$, so $g\in Z(G)$. QED
(More generally, the full marginal subgroup associated to $w(x) = x^n$ is the set of central elements of exponent $n$).
In particular, a sugroup of $G$ is marginal relative to $w=x^2$ if and only if it consists of central elements of order $2$. However, you are only checking that the elements be of order $2$.
(Added. It seems that you were only checking for elements such that $w(g)=1$; while this is necessary for $g$ to lie in the marginal subgroup, it is not sufficient.)
Thus, note that neither $N_1$ nor $N_2$ are $w$-marginal, since they both contain noncentral elements. The only $w$-marginal subgroups of the dihedral group of order $8$ are $\{1\}$ and $\{1,b^2\}$. 

As to the proof that a subgroup generated by (normal) marginal subgroups is itself marginal: let $N_1$ and $N_2$ be normal $W$-marginal subgroups of $G$, where $W$ is a set of words. Then $N_1N_2$ is a normal subgroup, and is the subgroup generated by $N_1$ and $N_2$. Let $w\in W$ be a word in $k$ letters, let $n_1\in N_1$, $n_2\in N_2$, and let $g_1,\ldots,g_k\in G$. We need to show that 
$$w(g_1,\ldots,g_{i-1},g_i(n_1n_2),g_{i+1},\ldots,g_k) = w(g_1,\ldots,g_n).$$
Since $N_2$ is $W$-marginal, we have
$$w(g_1,\ldots,g_{i-1},g_i(n_1n_2),g_{i+1},\ldots,g_k) = w(g_1,\ldots,g_{i-1},g_in_1,g_{i+1},\ldots,g_n).$$
Since $N_1$ is $W$-marginal, we have
$$w(g_1,\ldots,g_{i-1},g_in_1,g_{i+1},\ldots,g_n) = w(g_1,\ldots,g_{i-1},g_i,g_{i+1},\ldots,g_n).$$
Thus, the required equality holds. 
That is, for every $x\in N_1N_2$, for every $w\in W$,
$$w(g_1,\ldots,g_{i-1},g_ix,g_{i+1},\ldots,g_k) = w(g_1,\ldots,g_n).$$
Inductively, the result holds for any finite family of marginal subgroups. If $\{N_i\}$ is an arbitrary family of marginal subgroups, and $x\in \langle N_i\rangle$, then there is a finite set $\{i_1,\ldots,i_k\}$ such that $x\in N_{i_1}\cdots N_{i_k}$, and thus $x$ is itself marginal by the finite case. 
Thus, a subgroup generated by $W$-marginal subgroups is also $W$-marginal.
For some more on marginal and verbal subgroups, see this previous answer.
