The second grid is easier to analyze. There are $4$ choices for the B. From each of those choices, there are $2$ choices for the first A, $1$ choice for the N, $4$ choices for the second A, again $1$ choice for the N, and finally another $4$ choices for the third A. Thus, there are $4 \cdot 2 \cdot 4 \cdot 4 = 128$ paths that work in the second grid.
As for the first grid, there are $2$ partial paths that give you a corner N as the first N. From there, you can reach the second A either by backtracking or not backtracking.
If you don't backtrack, you have $2$ paths to another corner N for the second N (which gives you $2$ possibilities for the final A) and $1$ path to the center N (which gives you $4$ possibilities for the final A). This accounts for $16$ total paths.
If you backtrack, you have $1$ path to a corner N as the second N (which gives you $2$ possibilities for the final A) and $1$ path to the center N (which gives you $4$ possibilities for the final A). That accounts for another $12$ paths.
There are $2$ partial paths that give you the center N as the first N. From there, you have $2$ ways to choose the second A that are adjacent to the B and $2$ ways to choose the second A that are not adjacent to the B.
If the second A is adjacent to the B, the second N can be a corner N ($2$ choices for the final A) or the center N ($4$ choices for the final A). That accounts for another $24$ paths.
If the second A is not adjacent to the B, there are $2$ possible corner Ns to choose as the second N (each of which yields $2$ choices for the final A) and $1$ possible center N to choose as the second N (which yields $4$ choices for the final A). That accounts for the final $32$ paths.
Thus, we have a total of $32+24+12+16=84$ paths.