The breastfeeding that establishes the mahram relationship must meet two conditions:
1. That there should have been five or more breastfeedings, because of the hadeeth of ‘Aa’ishah (may Allah be pleased with her), who said: Among the things that were revealed of the Qur’aan was that ten definite breastfeedings make a person a mahram, then that was abrogated and replaced with five definite breastfeedings
Narrated by Muslim, 1452
2. That should be within the first two years of the child’s life, because it was proven that the Prophet (blessings and peace of Allah be upon him) said: “There is no breastfeeding except that which fills the stomach.”
Narrated by Ibn Maajah, 1946; also in Saheeh al-Jaami‘, no. 7495
Al-Bukhaari (may Allah have mercy on him) said in his Saheeh: Chapter on one who says there is no breastfeeding after two years because Allah says (interpretation of the meaning): “The mothers shall give suck to their children for two whole years, (that is) for those (parents) who desire to complete the term of suckling” [al-Baqarah 2:233].
There is nothing wrong with breastfeeding children with the aim of establishing the mahram relationship between them, because this is a permissible aim and there may be a need for it. The Messenger (blessings and peace of Allah be upon him) instructed the wife of Abu Hudhayfah to breastfeed Saalim so that he would become a mahram to her.
And Allah knows best.