Her Majesty has, on occasions, worshipped at churches of many denominations, including Roman Catholic. She attended Vespers at Westminster (RC) Cathedral on St. Andrew's Day, 1995, to mark the centenary of the commencement of its construction.
Her involvement in the Church of Scotland is on a different level from this. She is more than an occasional, or even regular, worshipper. She is a full member of the Church of Scotland, as well as being a full member of the of the Church of England. She is Supreme Governor of the Church of England only.
Lay members of the Church of Scotland are not required to assent or agree with all aspects of Church doctrine, and neither are lay members of the Church of England. So there is nothing inherently contradictory in being a lay member of either or both churches, without necessarily agreeing with either on a whole range of possible doctrinal issues. Both Churches regard Holy Scripture as paramount.
As Queen, she declared herself to be "a faithful Protestant" in February 1952 immediately she returned to London from Kenya, where she became Queen on her father's death. She also swore
I, Elizabeth the Second, by the Grace of God, of Great Britain, Ireland and the British dominions beyond the seas, Queen, Defender of the Faith, do faithfully promise and swear that I shall inviolably maintain and preserve the Settlement of the True Protestant Religion as established by the laws of Scotland ....
Similar promises in relation to England, and a promises to maintain within the United Kingdom the Protestant Religion, were made during her Coronation Service in 1953.
With regard to bishops, as curiousdannii points out, the Church of England does not necessarily believe that the apostolic succession of the episcopacy, via the manual transmission of the laying on of hands, is essential. It does however attach importance to the fact that it has maintained it and does maintain it; and has sought to remove some doubts on this by the involvement in C of E consecrations, since the 1930s, of Old Catholic bishops from the Utrecht Union. This is done without absolutely claiming that it is essential, but in recognition that some people think it is, or might be. If the Queen believes, in common with probably most Anglicans, that it is not essential then the different polity presents no personal problem to her.
The Church of England also teaches that every national or particular Church has the right to ordain its own rites and ceremonies. The Church of Scotland teaches that all Churches are more or less pure.
In fact, the Queen is not the only Church leader who might be accused, wrongly I think, of changing her beliefs according to which country she is in. The Pope, when in Rome, does not accept the canonicity of the 3rd Book of Maccabees, but there are Eastern Catholic Churches which do accept it. The Pope recognises these Eastern Churches as the authentic expression of Christianity within their respective geographical areas. Does he alter his beliefs when crossing the border?
Queen Victoria was the first monarch since the Union of the Crowns, 1603, to spend a significant amount of time in Scotland. She took Holy Communion at Crathie Church, near to her holiday home, Balmoral Castle, in the Aberdeenshire Highlands. This caused something of a furore in some parts of the Church of England, who argued that, as an Anglican, she ought, if she had wanted to take Communion, to have done so in the Scottish Episcopalian Church, the Anglican Church in Scotland. Victoria much preferred the simplicity in the Highland Kirk, to the more elaborate services she was used to in England.
Victoria pointed out that the bishops of the Scottish Episcopal Church were "mere dissenters". For one thing, unlike their English counterparts, they had not been appointed by her. Her view seems to have been that neither the Church of England, nor the Church of Scotland, was perfect, but that each was the authentic, national, brand of Christianity in its own country.
While accepting curiousdannii's argument that there is no theological objection to the Queen worshipping in any Protestant Church, given religious tolerance; I suspect the reason, at least historically, is more to do with recognition of the importance and status of a national Church within its boundaries.
There are many justifications for having multiple denominations, each with its own particular doctrine. But there are also arguments against schism and in favour of unity. At least to Queen Victoria, and I suspect to her great-great-granddaughter, the concept of a national Church, and the idea of unity as a good thing where it can be had (though not to be enforced), was more important than questions of whether or not to have bishops or any of the other things about which Christians may disagree.
The theological justification is that the unity and status of the national Churches is seen as of greater importance than the differences in doctrine.