Your problem is that you only check those values, if the form is valid. But as soon as you add a custom error you will never be able to submit. Additionally you do not need to submit the form programatically.
Here you find a a working demo for your problem
var setCountryValidity = function () {
var message = 'Please Enter different country ';
//only test if valid or is invalid because of this validity test
if ($("#country2").is(':valid') || $("#country2").prop('validationMessage') == message) {
if ($('#country1').val() != $("#country2").val()) {
message = '';
}
$("#country2").setCustomValidity(message);
}
};
//test if country1 was changed
$("#country1")
.on('change', setCountryValidity)
;
//test if country2 was changed and ...
$("#country2")
.on('change', setCountryValidity)
//... on DOMready
.each(setCountryValidity)
;