Constructing scheme for indistinguishability test with variable length messages
That homework assignment is not entirely precise: If you allow $|m| = p(n)$, the padding doesn't make sense: $0^{-1}1$. Therefore, you would have to limit $|m| \leq p(n)-1$ to avoid that case.

For your example and question: You're right, if you consider that a prefix $0^{-1}1$ actually is the empty string (no padding). Then your strings are equal. However, that case is actually undefined and should be fixed with reducing the message length by $1$.

From an information theoretic point of view:
There are $2^{n}$ messages of length (exactly) $n$. And there are $\sum_{k=0}^{n}2^k = 2^{n+1} - 1$ messages of length $n$ or less. So if you consider the set of all messages of length $n$ or less, and consider those shorter messages as different messages, then you actually have $n+1$ bits of entropy (rounded to the next integer) and need at least a message of $n+1$ bits length to encode that information.