This is because Shininess is dependant on your IDs alongside Personality Values.
wat do you mean bi 2 ids le scootch
Each trainer has two IDs, their normal ID and their secret ID. This is just a second ID number for a lesser chance a traded Pokemon is treated as your own (in case the two trainers have the same normal ID number).
Cool, now how did that Honedge turn into Shiny Aegislash? Well, here's how:
S = IDTrainer ⊻ IDSecret ⊻ p1 ⊻ p2
IDTrainer is your Trainer ID.
IDSecret is your Secret ID.
p1 and p2 are bits of your Pokemon's personality values.
⊻ is a bitwise exclusive or operation. Click on the link for more info.
If S is less than 16 (0-15) it is shiny. If it is equal or greater than 16 (15-65535) it isn't shiny.
Plugging in numbers, say the original Honedge owned had an ID of 32374 and a Secret ID of 31485, and the Honedge had a Personality Value of 2814471828 for this specific strand. Since it is all binary, this comes down to:
S = 0111111001110110 ⊻ 0111101011111101 ⊻ 1010011111000001 ⊻ 0110111010010100
S = 1100110111011110 (In Binary)
S = 52702 (In Decimal)
So, since S is equal to 52702, the Honedge would not be shiny.
But say this Honedge is traded to Shofu, who has the ID number of 24294 and a Secret ID of 38834. Then,
S = 0101111011100110 ⊻ 1001011110110010 ⊻ 1010011111000001 ⊻ 0110111010010100
S = 0000000000000001 (In Binary)
S = 1 (In Decimal)
So, since S is equal to 1 here, the Honedge would be shiny with Shofu.
However, since this doesn't magically just happen, the Honedge would either have to change forms or evolve, and the Honedge went through the latter, making Aegislash be shiny.