The value of media is a media query. If the query does not match, the element is not rendered and its resources and potentially its child resources will not be fetched. If the browser window changes size or orientation, the media queries are re-evaluated and elements are hidden and shown based on the new results.
The value of the AMP sizes attribute is a sizes expression that selects the defined size corresponding to the media query based on the current window size.