The red bottle's lid
Normally it would be the bottle that was red. Because "red" stands before "bottle", and "bottle's lid" is not a single compound noun but two separate nouns, the ordinary pattern of [adjective, noun it belongs to, anything else] take precedence over the less frequent pattern [adjective, noun that is the possessor of another noun, head noun to which the adjective belongs].
What kind of a lid do we have here? A red bottle's lid. Ah, but how do you know this lid comes off a red bottle? I see some glass splinters stuck to the lid.
Things change if you are using the first noun as a noun adjective, resulting in a compound noun:
The red bottle lid
In this case, "bottle" is a noun adjective, not simply a regular noun with the possessive s; that makes "bottle lid" a single compound noun. Then "red" belongs to the entire compound noun; and because the final element of a compound noun ("lid") is the head (the "core" of the compound), the adjective mostly describes a property of the head. The lid is red.
What kind of red lid do we have here? A red bottle lid. Ah, right.
The red lid of the bottle
Here "red" simply belongs to the first noun that follows it, because we have no compound noun, merely a prepositional attribute "of the bottle" and a head "lid".
What kind of a red lid do you have there? It is the red lid of the bottle! Huh, of what bottle? Oh, you know, of the bottle you got me drunk with yesterday, in order to have sex with you, which I would otherwise never have subjected myself to? Ah, right.