I wonder, if John was from England & Agnes from Ireland whether indeed they met in England, or whether John was for some reason in Ireland, perhaps military if there was something going on at the turn of the century that required Military in Ireland.
Yes, there was a lot going on in Ireland at the time.
Britain was at war with Revolutionary France, followed by Napoleonic France, 1793-1815, interrupted by an occasional brief truce. British Government feared revolutions in Britain and Ireland during this period. There was unrest in Ireland in 1790s and military repression. Irish revolutionary leaders sought help from France. There were rebellions in Ireland + a French invasion in 1798. The Irish Parliament was abolished at the turn of the century. There was another, abortive attempt at a rising by Robert Emmet.
There were army barracks in towns and cities all over Ireland in 18th & 19th centuries. Many regiments spent time there.
Regiments, both regular and militia, were also sent all over Britain during the French wars. There was a huge mobilisation of men for army, militia and navy for the long war. That may have been another reason for John arriving in Scotland, if he had been a soldier or militiaman.
A small number of wives accompanied regiments on long deployments. As a consequence, babies were born away from home.
Apart from a military reason; Ayr is a port and there were many ports on the west coast of England, trading with each other, with Ireland and with newer, more distant colonies.
Movements of people back & forth between the islands of Ireland and Britain had been happening for millennia. N.E. coast of Ireland to S.W. coast of Scotland is a short crossing. Weavers from Ulster were living in Ayrshire by early 19thC.