What is the theological justification for the British monarch worshipping in the Church of Scotland, rather than the Scottish Episcopal Church? When Queen Elizabeth II is in Scotland, she worships in the (Presbyterian) Church of Scotland, rather than in the Scottish Episcopal Church, which is in full communion with the Church of England.

The political reason for this is obvious, but how is this theologically justified?  (Or alternately, does no justification exist, with politics overriding theology?) How can the Queen believe in apostolic succession and episcopal governance south of the Tweed, and in Presbyterianism north of the Tweed?
There's no inherent incompatibility. Both denominations believe in forms of apostolic succession (though not the kind asserted by the Catholic Church.) Wikipedia explains:

The Anglican Communion &quot;has never officially endorsed any one particular theory of the origin of the historic episcopate, its exact relation to the apostolate, and the sense in which it should be thought of as God given, and in fact tolerates a wide variety of views on these points&quot;. Its claim to apostolic succession is rooted in the Church of England's evolution as part of the Western Church. Apostolic succession is viewed not so much as conveyed mechanically through an unbroken chain of the laying-on of hands, but as expressing continuity with the unbroken chain of commitment, beliefs and mission starting with the first apostles; and as hence emphasising the enduring yet evolving nature of the Church.
Jus Divinum Regiminis Ecclesiastici (English translation: The Divine Right of Church Government), which was promulgated by Presbyterian clergy in 1646, holds that historic ministerial succession is necessary for legitimate ministerial authority. It states that ministerial succession is conferred by elders through the laying on of hands, in accordance with 1 Timothy 4:14. The Westminster Assembly held that &quot;There is one general church visible&quot; and that &quot;every minister of the word is to be ordained by imposition of hands, and prayer, with fasting, by those preaching presbyters to whom it doth belong&quot;.

From the Presbyterian perspective, all Presbyterian elders are actually bishops. Pressies have the most bishops! The biggest difference between Anglicanism and Presbyterianism is that wherever Anglicans have one leader, Presbyterians will have a plurality. This happens at basically all structural levels.
The formal definition of the Presbyterian church structure that we know today was developed by the Westminster Assembly of 1643-1653. The Assembly was called by the English Parliament and was intended to bridge the divisions between puritans, the Church of Scotland (who already had a form of Presbyterianism), and the more traditional Church of England episcopalians. James VI &amp; I had said that he wanted to push episcopalian government on the Church of Scotland, which they, naturally, were not happy with. This conflict actually devolved into a couple of small wars (and arguably resulted in the English Civil Wars and the execution of Charles.) Against the wishes of Charles, the English Parliament called the assembly, and the majority of the assembly were Church of England clergy, though a few Scots were also sent. In return for a military alliance, the Scottish Parliament had required the English Parliament to bring its church government in line with the Scottish Presbyterian model. The majority of the people selected for the Assembly did support Presbyterian governance, and that's the conclusion they reached.
But Cromwell won the civil war before the Assembly could finish its work. His parliament established religious tolerance, and the Westminster Standards were not formally adopted in English. Individual parishes could adopt Presbyterianism, and 64 out of London's 108 did. But when the monarchy was restored the Assembly was repudiated, and laws were passed that returned the Church of England to a strict episcopalian structure. As a result, as many as 2500 ministers left the Church of England.
I think the theological justification is that the Church of England has never seen itself as the only legitimate church. It has always recognised its sister church in Scotland, even before the Westminster Assembly when the initial form of Presbyterian polity was in place. The Church of England has its own theological arguments for episcopalian polity, but it can't deny that Presbyterianism has strong Biblical and theological backing, and that it has a long history in England and could have become the official position of the Church of England had some battles turned out differently. For the British monarch to worship in different denominations is natural given that the English and Scottish crowns are separate. It would also be appropriate for the monarch to worship in other unestablished Protestant denominations in recognition of the centuries old (and hard won) principle of religious nonconformity.