"the Queen might be assaulted while I was strolling by Buckingham Palace"
As noted in bookmark, p.205, the role of guardsmen was (and is) to protect the Sovereign and her properties.
In London the guardsmen are responsible for the security of Buckingham Palace
, St. James's Palace
, and the Tower of London