I've had this happen a few times where you are notified of a settlement attack and when you get there one of the settlers is the one attacking. This last time it was at the Castle and it also came coupled with the settlement defense glitch where you kill the attackers, the settlers thank you for taking care of them, but the quest doesn't update causing you to fail it when you leave the area.
In this case it was definitely a settler and in fact one I had assigned to the clothing shop, which after the whole ordeal was vacant and had to assign someone else to. She and, minutes later, a random raider who spawned near the same place were the only attackers. To get the quest to update I had to resurrect her corpse several times and re-kill her (I guess to kill the specific number of attackers the game is expecting to die to complete the quest).
Interestingly when I tried to resurrect/recycle the raider (he was blown to bits), he just disappeared and never came back. Also when I resurrect and recycle the settler, she would morph into a different settler body each time but I am guessing that is because I was using recycleactor. But it would always immediately attack.
So obviously this was a heavily glitched quest but here's what I don't understand yet, especially given it has happened a few times: was the settler attacking her own settlement part of the story or a glitch? Do settlers "go bad" and maybe join up with the raiders? I thought maybe she was a disguised synth but she had blood and guts like humans.