you would think they would learn and make a couple less XS and XLs and a couple more mediums?
Keeps demand high I suppose
I doubt the demand for different sizes is exactly the same year to year. It will depend which customers are buying in a given year, and what they are buying. Some years there are bound to be more small or large riders who take it upon themselves to buy a new bike than others. In the case of carbon frames the situation is a bit more complicated. Because they are made in moulds, to make the most efficient use of them they have to fully utilise them. Let's say you've got 20 moulds. The minimum percentage of any one size you can build is 5%, and your capacity changes in 5% increments.
At the extremes of sizing, you might have an 8% demand for XS, and a 9% demand for XL, but the most efficient quantity to build is 10% of each. In the middle of the size range, natural demand for Medium might be 41% but the most efficient number for you to build is 40%, using 8 moulds. Therefore the Medium will always sell out with actual demand slightly exceeding capacity, but some sizes capacity will slightly exceed demand. When the most popular sizes are fully sold, the manufacturer has to entice riders who couldn't get their exact size to buy one of the overstocked sizes and the usual way is to discount. The reason it hasn't happened much this year is the supply was low even in the less popular sizes so everything will have sold, and a greater proportion of riders will have had to settle for a sub-optimal size in order to get anything at all.