Input and stock are strings.
When increasing the amount in the cart your function is comparing string values.
When increasing the amount in the cart your function is comparing string values.
You should convert to floats, something like this:
var UpdateQuantity = debounce(function (input, stock) {
i = parseFloat(input.value);
s = parseFloat(stock);
if (i <= s) {
input.classList.remove("is-invalid");
input.closest(".js-input-group").querySelector(".js-not-enough-stock").classList.add("d-none");
console.log("submit");
document.querySelector("#ordersubmit").submit();
} else {
input.value = stock;
input.classList.add("is-invalid");
input.closest(".js-input-group").querySelector(".js-not-enough-stock").classList.remove("d-none");
}
}, 300);