As you have stated, what you want to say is:
The number of coins in bottle A and the number of coins in bottle B are compared.
This is grammatically correct.
In asking which of these is correct:
The number of coins in bottle A and bottle B is compared.
The numbers of coins in bottle A and bottle B are compared.
from your extended question you can construct the contraction by omitting the repetition, thus:
The number of coins in bottle A and [the number of coins in] bottle B are compared.
The number of coins in bottle A and bottle B are compared.*
This is both correct and would be understood to mean that you have compared the number of coins in each bottle (and found that the number of coins differs or is the same).
Because the number(s) of coins are properties of the bottles, and the bottles are named separately; the number of coins in bottle A where number (referring to quantity) is singular because there is only one bottle, and are compared is the plural form because there are two bottles. And you have quantity (s) of objects (pl) in objects (pl), which becomes cumbersome if it were plural-plural-plural.
The weight of bottle A and bottle B is compared.
is not correct; the case is slightly different here. The weight of bottle A is compared with the weight of bottle B., when rearranged, becomes The weight of bottle A and the weight of bottle B are compared.
The weights [of] bottle A and bottle B are compared.
Whether you say weight (s) or weights (pl) can be open to interpretation, but in either case it will be are compared.
Also, using the passive voice is often less clear than using the active voice.
* The numbers of coins in bottle A and bottle B are compared is also correct.