Overide the file
vendor/magento/module-ui/view/frontend/web/js/view/messages.js
TO
app/design/frontend/YourPackage/YourTheme/Magento_Ui/web/js/view/messages.js
Comment Out the below code,
onHiddenChange: function (isHidden) {
var self = this;
// Hide message block if needed
if (isHidden) {
setTimeout(function () {
$(self.selector).hide('blind', {}, 500);
}, 5000);
}
Finally execute upgrade,Content commands