A man who grabbed the flag that was draped over Queen Elizabeth II coffin planned to trespass at royal residences including Buckingham Palace.