Extending the answer of bjcolby15:
It is assumed that all of the weights are only allowed on one side of the scale and the object to be weighed is on the other side of the scale.
Any positive integer can be expressed in base $2$ format. In such a format, each digit in the expression will be either $1$ or $0$. This bijects to determining which weights to use to weigh the object.
For example, $7$ equals $111$, written in base $2$. This corresponds to using the three weights of $4$, $2$, and $1$ to equal a weight of $7$. Note, that under the assumption that each weight is either used on a specific scale or not, there are only $2$ choices for each weight. Either use it or not.
This is why base $2$ is so relevant. Because for each digit in a base $2$ representation, either the digit is $0$ (which corresponds to not using the weight) or $1$ which corresponds to using the weight.
See also, the Addendum below, which discusses an alternative assumption re the use of the weights.
Addendum
Changing the assumption of how the weights are to be used:
Suppose instead, that you place an object on the left scale, and that the weights may be placed on either the left scale or the right scale. This means that instead of having only $2$ choices for how to use each weight, you have $3$ choices:
Use the weight on the left scale, along with the object to be weighed. Imagine assigning the number $-1$ to the weight here.
Use the weight on the right scale, opposite the object to be weighed. Imagine assigning the number $+1$ to the weight here.
Don't use the weight at all. Imagine assigning the number $0$ to the weight here.
So, you have $3$ choices. This roughly corresponds to expressing numbers in a variant of the normal base $3$ format: instead of using the digits $0,1,2$, you use the digits $0,+1,-1$.
This is why (for example) $4$ weights are sufficient to weigh any object up to $40$. Because the weights of $1,3,9,27$ are used. Note that $\displaystyle 40 = \frac{3^4 - 1}{2}.$