vectorize() should only operate on its direct operands. If it is applied to a function f(), it must alter only arguments to that function: all arguments to f() that are matrices must not be actually passed to f(); instead f() must be evaluated separately for each nth element of those arguments.
But this doesn't mean that vectorize() may alter the inner structure of f(). Each invocation of f() inside vectorize() for an argument's element must be exactly the same as if f() would be explicitly called for that element without vectorize(), regardless of optimization mode. So, vectorize() must not descend inside functions regardless if they themselves contain matrices or not. Failing to do so is disastrous for calculations. It leads to unpredictable results; it doesn't allow for some uses of vectorize(); it makes built-in and plugin functions behave differently than defined in sheet (thus making user functions a second-class citizens).
So, vectorize() must not perform any optimizations on its arguments before deciding which resulting items will be subject to vectorizing; instead, it must decide which names (items) are subject to vectorizing, before optimizing arguments, and do further optimizations while substituting those items with dummy (unused) names, so that it may later safely iterate the optimized results, substituting elements for dummy parameters back.
Attached is the demonstration of the problem.