I don't know the underlying reason behind why you do this, but it's an interesting post. Interesting to me because I think that you show a great deal of insight into this situation. You are self aware too. You realise that this "attention behaviour" is possibly not necessarily serving your own mental health well in the long run?
I always say if something doesnt' serve you well then you need to look at what you need to change in order to achieve a sense of peace within yourself because it doesn't seem to me like this behaviour is necessarily working out for you.
I hope that you are able to substitute strategies and use different methods to show people that you care about them and they will care for you in return if they believe that your intent is to form meaningful friendships.
I think you can do this