The human being is a social creature and in need of connecting with others in order to survive. Nevertheless, he should secure his prosperity and salvation in this world and the next by selecting a worthy friend and keeping the friendship moderate, away from all exceeding of the limits or breaking Allah's (swt) laws.
Love denotes the highest level of affection for a person or thing and can be categorized into three types:
1) True Love; a love that lays deep inside the heart and begins and ends with Allah. There are other terms that are used for this type of love, such as ‘The Great Love’.
2) Metaphoric Love: Love whose subject is things in this world created by the Lord, such as the love one may have for another person and his virtues, this love is also called ‘The Smaller Love’.
3) False love: This love originates from lust and carnal desires and allows the nafs ammarah to take control and strengthen and leads to the domination of lust over one’s mind, resulting in one’s corruption and decline.
Any love for other than Allah (swt) and the infallibles is false.
The ways to prevent such friendships or free oneself of them can be counted as the following:
a) Being careful when choosing friends and observing Islamic laws (gender-wise) in the process.
b) Paying attention to the negative outcomes of excessive friendships.
c) Strengthening one’s true love (love of Allah (swt)) because if this love grows in the individual, other loves will fade away.
Three points are important in answering this question:
1- The Importance of choosing friends: Because humans are social creatures, they need to make friends in life. Since youth are usually at the verge of entering society, choosing an appropriate friend and companion is of higher importance to them.
At the same time, we must keep in mind that much of the corruption and crime that takes place is the result of inappropriate friends, thus having good friends and interacting with them can contribute greatly in the blossoming and development of youths’ potentials and personalities and the strengthening of their different dimensions, spirituality and qualities.
To put it like this, friendships that are based on logical principles and are in accordance with Islamic guidelines and far from excessiveness can be seminal golden opportunities, or else they can entail dark destinies.
In the Quran, Allah (swt) says: “A day when the wrongdoer will bite his hands, saying," I wish I had followed the Apostle's way! Woe to me! I wish I had not taken so and so as a friend…” 
The noble prophet (pbuh) says regarding the importance of friendship: “Each person takes on the religion of his friend, so be careful whom you befriend.” 
It is because of this that paying attention to who one becomes friends with can guarantee a good life in this world and the next.
2- Maintaining moderateness in friendships: A very important matter when it comes to friendships is moderateness when expressing friendship and observing the limits and keeping it in the framework of Islam and away from excessiveness.
The reason being that sometimes friendships get out of hand and turn into corrupt passionate relationships. In order to draw the line between good and desirable friendships and undesirable ones, it is necessary to give an explanation on love and its different types:
In dictionaries, the term ‘ishq’ (love) is defined as extreme affection  ,  . This term derives from the root “عشق” which is a plant that wraps around other trees.  When affection for someone or thing reaches its highest, in a way that it takes total control of the person and just dominates him, it is called ‘ishq’ (love); this love is categorized into three types:
1- True love: In the Islamic dictionary, true love is the worship of Allah (swt) and as Imam Ali (as) says: “How blessed is he who falls in love with worship and loves it with his heart and performs it with his body.” 
Allamah Tabatabai defines true love as such: “Love means for a creature in pursuit of perfection (man) to be attracted to total perfection (God) meaning the All-Beautiful and All-Sufficient...and the beloved one whom all are aiming for.”  Therefore, true love is love for what is absolute goodness without any deficiency; this is the highest level of love. It is a love that is embedded deep in man's heart, beginning and ending with Allah (swt). This love is also called “The Great Love” and “The First/Third Affection”. 
2- Metaphorical Love: Mystics and Philosophers have listed two more types of love; metaphorical and false love.
Metaphorical love is love one may have to creation and the manifestations of the Lord, such as love of other people and their good qualities, all of these being manifestations of Allah (swt). This love is also called ‘The Smaller Love’. Nevertheless, halting and remaining at this stage of love, although having it is better than not having any love at all, doesn’t entail the results true love has.  Modest and pure metaphorical love serves as a ladder and passage to the realm of true love.
False love is love that originates from lust and carnal desires. Here, the one in love is amazed by the face and external traits of the beloved one. This love, which has wrongly been given the name of love, allows the nafs ammarah and one’s desires to take over and strengthen, leading to his lust taking control of his mind, resulting in his corruption and decline. False love is in reality none other than the outburst of lust; a love originating from animalistic desires. 
The Late Shahid Motahhari says regarding this love: “A youth, who by seeing a pretty face and curly hair shakes inside, or by the touch of a soft hand becomes weak in the knees, must know that all of this is only animalistic and materialistic. These types of love come quickly, and perish quickly; they aren't reliable nor recommended; they are dangerous and wipe out virtues. The only way one can capitalize off of them is to not give in to them and remain modest and chaste.” 
It is because of this that one should abstain from such love and false affections that originate from carnal desire, because this love ultimately ends in violence, crime, preoccupation, burdens and regret. The main way to free oneself from this love is to strengthen one’s ‘true love’; if this love grows in a person, other false loves will automatically fade away and he will become aware that no one other than Allah (swt) truly deserves to be loved, and instead of external beauties like eyes, hair and faces, one should be after their creator who is the true bearer of beauty.
Of course, to consolidate such love in oneself, the grounds for such must be set, it is only then that such a thing will be possible.
About how one can prevent excessiveness in friendships, and how not to suffer from false love, several points need to be considered:
1- When choosing friends, we must be very careful to choose those who have worked on themselves and developed in their Aqaid, Akhlaq, etc. and are ahead of us, and as the prophet (pbuh) says about the good friend: “Seeing him, reminds you of Allah (swt), his speech adds to your knowledge, and his behavior reminds you of the hereafter.”  Imam Hasan (as) advised his son: “O’ my son! Don’t befriend anyone unless you know where he goes and who he sits with, and when you become well aware of his circumstances and approved of them, befriend him. Your friendship should be so that he prevents you from sin, and so that you help him in poverty.” 
In other words, when choosing friends one must observe Islamic law (gender-wise) and the limits set for friendship, namely:
a) Friendship should be for Allah's (swt) sake and with the goal of getting His satisfaction, not for worldly desires. 
b) Maintaining moderateness in friendship and abstaining from excessiveness or shortcoming. 
c) Choosing friends only after doing research about them and testing them. 
d) Abstaining from telling personal and important secrets to them; even the closest friends. 
e) Not to go too far in trying to find out about the personal affairs of the lives of friends.
f) Staying away from those who openly commit sins and try to make it look good to you. 
g) Staying away from liars, sinners, the miserly, ignorant and unintelligent, those who break their family ties, those who are badmouthed, despicable and mischievous individuals. 
2- A realistic look at the negative outcomes of excessiveness in friendship, because:
a) Even our closest friends might someday end up straying from the straight path, and if we can't distance ourselves from them then, we will also be prone to their deviation.
b) Life is very unpredictable and many incidents may take place in its course that will bring about separation between two friends; excessive affection will make such a separation very hard and bitter, and in many cases will end in a powerful blow mentally and emotionally. 
c) Sometimes when affection and love get out of hand, they end in one side sexually taking advantage of the other, or both committing such an act; in any case, this will lead to irreparable mental and moral harms to one or both sides.
d) Excessive love prevents intellectual and social development, especially in youth, because it causes them to cut off from their families and other communities like school and masjids and to forget about their studies, worship, and spirituality. 
e) Remember that all love other than love of Allah (swt) and the infallibles is false and transient. 
For further information, see:
1- The mathematical mind, the heart, faith and love, Question 175 (website: 937).
2- Love from philosophy and mysticism’s perspective, Question 881 (website: 961).
 Furqan:27 and 28.
 “ المرء علی دین خلیله،فلینظر احدکم من یخالل ” Biharul-Anwar, vol. 74, pg. 192.
 “ العشق افراط الحب و یکون فى عفاف و فى الاساس «اشتقاق العشق من العشق ... ” Aqrabul-Mawarid, vol. 2, pg. 786.
 Adopted from: The Mathematical Mind, the Heart, Faith and Love, Question 175 (website: 937).
 Jubran Mas’ud, Al-Ra’id (with the translation of Reza TorabiNezhad, vol. 2, pg. 1190.
 “ طوبی لمن عشق العبادة و أحبها بقلبه و باشرها بجسده ” Usul Kafi, vol. 2, pg. 38.
 Tabatabai, Muhammad Husein, Al-Mizan, pg. 411.
 See:Porsekha va Pasokhaye Daneshjouyi, Erfan va Tasavvof, vol. 12, pp. 231-232.
 See:Porsekha va Pasokhaye Daneshjouyi, Erfan va Tasavvof, vol. 12, pp. 231-232, with slight modifications.
 The same reference above with slight modifications.
 Morteza Motahhari, Jazebehe va Dafe’eye Ali (as), pg. 56.
 “ قال من ذکرکم بالله رؤیته،... ” Biharul-Anwar,, vol. 74, pg. 186.
 Mohammad Javad Tabasi, Huquqe Farzandan dar Maktabe Ahle Beyt, pg. 176.
 Ghurarul-Hikam, vol. 2, hadiths 1795 and 1796.
 Nahjul-Balaghah, saying 268.
 Ghurarul-Hikam, vol. 2, pg. 86 and pg. 810.
 Biharul-Anwar, vol. 4, pg. 177.
 Biharul-Anwar, vol. 74, pg. 190.
 Khisal Saduq, vol. 1, pg. 244; Usul Kafi, vol. 4, pg. 453; Kanzul-Ummal, vol. 9, haditjh 24844.
 Nahjul-Balaghah, Saying 268.
 Sabah Research Periodical, nos. 7 and 8, 1991, pp. 24-26.
 Adopted from: Love and the Human Mind, Question 1822 (website: 2935).