Security won't necessarily just attack wanted ships. So your logic is flawed. It takes a few seconds for the scan to complete. It's not immersion breaking, it's part of bounty hunting - does the target have a bounty - it's in fact an actual key part of the process.
All because people can't stop holding the trigger down for a few seconds to validate the target status. Remember how people endlessly complain about AI that instantly start firing without scanning and how is that fair or reasonable? My immersion!
Works both ways. Scan the ship, if it's a perp - blast it - it's not much to ask.
Eh... The Developers thank you for defending them, you should receive your customer of the year reward soon.
I have never seen Security attack a clean NPC. I've seen them flip on a dime to attack NPCs and players that gained a bounty mid-fight. But, just outright attacking clean NPCs for the hell of it? Nope.
So no, my logic is not flawed and my statement stands: "it is a clunky, counter-intuitive, and immersion breaking system". It can be better than it is now, and should be.