Can't we have flexible block size? For example, each block confirming 4% of total transactions (numbers are only for example).
Apart from what ETFbitcoin wrote - it would simply be impossible to verify if the max block size is correct, because "the number of transactions in the mempool" is a different number in all nodes, and also grows over time - there is another problem with your idea: it would lead to a situation where a big part of the transactions would never be confirmed. If you set 4% of mempool transactions as a maximum per block, then on average only 4% of a larger period would be confirmed if the demand stays constant, so 96% would be discarded. This would lead to people trying again and again, demand growing all the time, and thus larger and larger blocks. It's even likely people create spam transactions just to increase the chance their legit transactions go through ...
You guys here underestimate how bad high transaction fees are for bitcoin adoption. Rich guys can pay high fees but poor or middle-class guys can't pay high fees. That's why they move on altcoins.
That's why sidechains (and similar technologies like rollups) are so interesting, but those that exist all have flaws. There's no completely decentralized design in production stage, Stacks is maybe the most advanced but still has centralized elements and relies on a premined altcoin to work. And of course LN.