All stages can, should and in fact must count towards the GC unless cancelled. If conditions necessitate it, the organisers can neutralise it or the péloton can protest it. Sometimes with justification (2009 Milano circuit, with cars etc. getting on it), and sometimes less so (2020 Giro when Adam Hansen got up in the morning, saw it was raining and didn't fancy it), but those races should count towards the GC, otherwise we're heading dangerously down the rabbit hole of Paris-Dakar with set timed sections and set liaison sections. Road cycling is a race from point A to point B, and any point between is a valid place to gain time. And yes, that does include crashes, although the unsporting nature of that means repercussions ought to be expected from the rest of the péloton in the circumstances. I mean, do we really want rid of stages like the 2010 Giro stage Pozzato won, where on a day expected to be for the sprinters, he initiated a move that people like Basso and Scarponi got into and turned it into a GC day? How about that Tour stage when Froome, Sagan and Bodnar escaped to gain time in 2016? 2011 Contador into Tropea? Quintana gaining 5 minutes into Guadalajara in the 2019 Vuelta? The stage 7 echelon slugfest in the 2020 Tour which was probably the best stage of the entire race, where the soporific GC battle was enlivened by an aggressive push for the maillot vert by Bora, who daren't ease up at all in the first hour or two lest Bennett get back on to contest the intermediate? Those were all stages which were designated flat but wound up providing more action - and crucially, more significant action - than would ordinarily be the case.
Yes, a lot of flat stages are boring, interchangeable and irrelevant, and certainly in a lot of them where there's no reasonable outcome other than a sprint, the fact today's péloton never even lets the break get far enough up the road to dare to dream in these stages (to the point where on occasion - Tour 2020 stage 5 - they don't even bother) renders them particularly dull. This year's Tour, however, has done everything in its power to make the flat stages interesting, riding through areas that bait echelons and similar to try to encourage action. Encouraging more selectivity and decisive stages in flat stages to reduce the size of the bunch coming in to the finish together is a positive idea, but we can't (sadly) get Classics-style action daily from GT flat stages, because cumulative fatigue means sometimes these obstacles will be soft-pedalled by riders just seeking to make it through the day. And unfortunately that is still often reliant on the weather and, as we've seen in the Vuelta, if the weather doesn't play ball with those stages it can be absolutely dreadful, but you can't just say "don't count that stage" in order to prevent GC riders getting hurt or crashing out, because what if the weather does play ball? Part of the fun with the Classics is that the bad weather at that time of year often plays a role that it simply can't in either the Tour or the Vuelta except on rare occasions (Angliru 2002, looking in your direction here), but can - and indeed often does - in the Giro.
What if some GC man spots that others are mis-placed and anticipates a split in the péloton late on to gain a few seconds (like Bernal did the other day)? We can't just erase those possibilities because it would suck if a GC guy crashes out. GC guys crash out of every GT. Like, every single one. Bike racing involves 100 or more riders riding along in close proximity to each other for several hours, and a touch of wheels, a loss of concentration or trying to grab a bidon, a musette or adjust your safety equipment can be all it takes to cause a crash.
Maybe we need tighter regulation on what roads are suitable for a finish in World Tour races in stages classified as flat, or where we are looking at a group of >50 coming to the line together, to get rid of the likes of that downhill Katowice finish, and some actual proper enforcement of the rules within sprints based on the action and not the outcome but that's all really. I say in World Tour races because a finish that is no problem for a péloton of 90-120 including some WT, some Pro and some Continental teams in, say, the Danmark Rundt, may not be suitable for a péloton of 180-200 almost all WT riders who are expected to be closer to each other in level, and where stages that might produce some time gaps in smaller races where riders' level and form varies far more often are less likely to do so in stages of major races where the field is almost all high-level riders at peak form.
Edit: added paragraph breaks