It isn’t just a Royal navy Tradition.
In WW2 when a sub returned to port it flew a Jolly Roger if it had sunk an enemy vessel.
US subs flew a broom if they’d scored kills/had a successful “sweep”.