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.