When I encounter an NPR in a new system I usually park my ships at the entrance, activate the transponder for a bit and then just leave the system.
With this I make sure they know my civ exists while minimizing the stress I cause them for having ships in their territory.
If they don't know you exist and you start communications all it does is improving your civ's opinion of them, but their's will stay the same.
Obviously they won't grant any privileges either.
So my guess is when you found the NPR you pulled your ships back before they could detect them, after which you started one-sided diplomatic communications.
When they didn't show any reaction you wondered what was going on and took a peek with another ship, at which point they finally noticed you.
They fired at you, you pulled back without retaliating, and somehow their opinion of your civ improved enough to grant trade access.
Not sure why they fired so few missiles, though.