If the instructor was not aware of the earlier interaction, she wouldn't have known that the friend initiated the contact and that the family was apparently comfortable with your presence. It would have looked like you were the one striking up the conversation, and the instructor's caution would have been not only correct, but necessary.
Why didn't you just explain that the friend and family members (including the patient) had started the ball rolling earlier and you were simply saying goodbye?
Instructors are only human. If an important piece of the puzzle is missing, it might be good to supply it rather than get all bent our of shape because she didn't understand.
On the flip side, having had the earlier conversation with your friend, it probably wasn't necessary to interrupt a conversation to go say goodbye to him. You were there to attend clinical, not to socialize.
I would caution you further that, while what took place doesn't appear to have broken any rules, encouraging friendship or a social connection while at a clinical or on the job can predispose you to errors down the road. You can still be friendly in your demeanor, but I really wouldn't encourage a lot of interaction with people you know (who are not your patients). Even though you understand the boundaries, they don't. They might mention aspects of their treatment with you before you can stop them and put you on the spot. Without doing anything wrong, you might still end up knowing more than is good for you or for them. Also, people who feel vulnerable sometimes spill their guts and feel awkward about it after the fact. It's better for you to set the boundaries that will help avoid this.
Even if they say something about their treatment and you do nothing more than refer them back to their doc or their nurse, their confidences can create discomfort. And heaven help you if your expression or anything you say creates a question. It wouldn't take much for one of them to say, "When I told that other nurse what meds I'm taking, he made a funny face." You might have. You might not have. It doesn't matter. You just don't need that kind of hassle while you're still in school. Or after.
Bottom line--be friendly but not overly so. Extricate yourself from any and all confidences regarding someone else's patient. Don't go out of your way to recognize or say hello or goodbye to people you know from other areas of life. If they initiate contact, be cordial but brief. Keep a professional distance between you and other people you know. It may feel odd at first, but eventually, it will come naturally.