A few months ago, in our group meeting, my advisor brought up a problem in the field that might be interesting for us to think about it. Although it was not related to my PhD, since I was going for my defense, I started to think about it with another student and prepared a paper and sent it to the advisor. He saw it (one week before the deadline) and said that another student in the group (who was in that meeting) is also interested in that problem and is working on a simpler version of it with a totally different approach.
9 hours before the deadline of the paper submission, the guy who was working on the simpler version sent me a message and said that I have to add his name (and also his wife!) to our paper because he was working on the same problem and he wants his name to be on the first paper which is about that new problem. He said that in return, he will add my name and my collaborator's name to his paper (his wife is his collaborator in his paper, although her field was not related to the problem and that is why he asked for both names to be added in our paper). I didn't have any contribution in their paper and they didn't have in ours and I didn't even know what is in their paper.
I am the supervisor of our paper and adding another two PhD students to my paper (even if we could ignore the ethics!) vanishes my role in having supervision in all parts of the paper (including the code and results), and it was really hard for me. I said that I cannot do it and we will submit our papers and see what will happen. In my whole research time, this never happened to me and it is so weird to me that why I shouldn't say no and face such complaints.
I did ask my advisor about this. He said that it was our fault that we didn't communicate about our projects, but he is okay if we want to exchange the names.
Did I do something wrong? Would you please suggest the right answer for such requests? Can he annoy me in the future?