In order for something to have weight, there are two requirements;
- It must have mass, i.e. it is composed of matter, not energy
- It must be in the presence of a gravitational field
If an object was floating in deep space, with no planet nearby, we could not say that it has "weight".
What may seem surprising about air having weight is that we can't see it; this is counterintuitive because we expect "objects" to be substantial, meaning that we can touch and see them. You can touch air, such as by waving your hand rapidly, but in everyday terms, air feels like it's some sort of exception to the rule.
Nevertheless, there are various ways of demonstrating that air does indeed have weight. This indicates that air is made of matter, and that despite changes in its appearance, it retains the basic property of weight.