How do filters and gas masks work?
The answer is a combination of Draedalus' answer and Kotekzot's comment.
Gas Masks & Replacing Them
Gas mask replacements only come up when the gas mask you are looking at (e.g. you are aiming at a discarded mask on a shelf) is in better shape than the one you are wearing; meaning it has taken less damage than your current mask.
The fact that it only lets you interact with a mask that is in better shape than your own makes it easy for you to make the decision to pick it up. There is no downside to doing so, considering how out of hand the cracks can get.
Filters & How They Work
The time that comes up when you pick up a filter is simply a consolidated reservoir of time that you have collected. It is really only there because the amount of "clean air" a filter you pick up can provide differs from one filter to the next. For instance, sometimes you might find a pristine filter that adds a full 5 minutes while other times a filter you find in a precarious area (on a dead body, for instance) may only give you a minute and a half.
That is the only reason it shows you a total amount of time you have saved up in terms of minutes/seconds of potential filtered air. Otherewise the game would have to keep track of each individual filter you've picked up and how much time is attached to each; in essence the developers were either lazy and didn't feel like doing that or thought it would be too tedious for the players.
That said, no matter what - as you know - when you replace your filter you get a set amount of clean air (e.g. 5 Minutes). If you replace your filter before the time is completely up, then you are wasting potential clean air as you are not getting that remainder of clean air refunded to your total. So if you replace your filter as soon as the 1 minute warning alarm goes off, you are losing that minute.
Additional Note: However, it should be noted that if you are playing on normal, then filters should never be an issue. You will have 30 or more minutes worth of air through most of the game at all times; the filters are absolutely everywhere in this mode.
What happens to my current filter when I pick up a new gas mask? When can I pick up a new gas mask?
Changing your actual gas mask has more to do with damage you take than air you are using. So if you have quite a few cracks in you mask because you have been fighting nosalis's, and you find a new one, you can pick it up for better vision, and possibly (read: I don't know but I suspect) so that you don't leak as much air. Also when you change masks, they come with a new filters, and you lose the contents of the old filters.
Are my filters magically consolidated like ammo from half-full clips I reload, so I can change a filter every minute without wasting filter capacity?
I don't think this is how it works. It seems that you collect filters with 5 minutes each, and when you change it you lose whatever remains in the filter. So my recommendation is to make each filter last as long as possible and only change them when a few seconds remain.