I definitely would also feel uncomfortable buying someone’s coffee if I had turned around and seen the person behind me was an attractive man by himself.
What I think I would have done is not wait till there was another customer and asked the barista to put “the next person’s coffee” on my card. Or maybe given her $5 and said to use it to pay for the next person’s order. That way I wouldn’t even know who they were and might be long gone by the time they get there. I would prefer that anyway. I wouldn’t want to be identified and have someone come up and thank me.
It’s funny — I think I just realized this works better at a drive-thru (something I’ve heard of people doing) where you can just say you’ll pay for the next car’s order and then drive off.