Assume $B = X\sqcup Y$, where $X$ and $Y$ are open in $B$. Suppose $X\neq \varnothing$. Letting $X_A = X\cap A, Y_A = Y\cap A$, we have $A=X_A \sqcup Y_A$ (since $A\subseteq B$, $X_A$ and $Y_A$ are open in $A$). Since $A$ is connected, either $X_A = \varnothing$ or $Y_A = \varnothing$. These two cases are handled separately.
If $X_A = \varnothing$, then $X\subseteq \partial_M A$. In paricular, there exists $x\in X\cap \partial_M A$ (since $X$ is assumed to be nonempty). Any $B$-neighborhood of $x$ then contains points from $A$, and therefore points from $Y$ (why?). This means that $X$ is not open in $B$, a contradiction.
Now suppose $Y_A = \varnothing$, so that $A\subseteq X$. The same argument as above shows that $Y=\varnothing$, for if $Y$ contained a boundary point of $A$, then $Y$ would not be open in $B$.
Thus, $X=B$ and $Y=\varnothing$. It follows that $B$ is connected.