When you find sets $A$ and $B$ such that $A\subsetneqq B\subseteq S$, you’re really dividing $S$ into three parts: things that are in $A$ (and of course also in $B$), things that are in $B$ but not $A$, and things that are not in $B$. In other words, evern element of $S$ belongs to exactly one of the sets $A$, $B\setminus A$, and $S\setminus B$. Conversely, if you divide $S$ into parts $X,Y$, and $Z$, you can let $A=X$ and $B=X\cup Y$ to get a pair of subsets $A$ and $B$ of $S$ such that $A\subseteq B$.
There’s nothing in the statement of the problem that prevents $A$ from being empty, so there’s no harm in letting $X=\varnothing$. There’s nothing that prevents $B$ from being all of $S$, so there’s no harm in letting $Z=\varnothing$. But we’re told that $A\subsetneqq B$, so $B\setminus A\ne\varnothing$. Thus, we must ensure that the part $Y$ of our $3$-way split of $S$ gets at least one member.
In order to build such a division of $S$ into $3$ parts, you can go through $S$ one element at a time, assigning each element in turn to $X$, $Y$, or $Z$. That’s a sequence of $n$ $3$-way choices, so by the multiplication principle it can be made in $3^n$ different ways. That is, there are $3^n$ ways to divide up $S$ into the $3$ parts $X$, $Y$, and $Z$, from which, as noted above, we get $A$ and $B$ by setting $A=X$ and $B=X\cup Y$.
However, that calculation failed to take into account the requirement that $Y$ be non-empty. How many of these unwanted divisions are there? They are essentially just divisions of $S$ into two parts, $X$ and $Z$, and the same reasoning that we used in the previous paragraph shows that there must be $2^n$ of them. Subtracting them, we find that there are $3^n-2^n$ divisions of $S$ into $3$ parts $X,Y$, and $Z$ with $Y\ne\varnothing$, so that when we set $A=X$ and $B=X\cup Y$, $A$ really is a proper subset of $B$.