I wanna know which inspired from which
To my knowledge, neither.
King Arthur: Legend of the Sword, King Arthur and even the 1963 Disney movie The Sword in the Stone, 2008 TV series Merlin and 2004 Japanese Visual Novel Fate/Stay Night take inspirations from the The Legend of King Arthur, otherwise known as the Arthurian legend.
According to the wikipedia page for Baahubali: The Beginning:
The film was conceived by Rajamouli's father K. V. Vijayendra Prasad, who randomly told him a story about Sivagami, a woman who carries a baby in her hand while crossing a river, and a few years later about Kattapa, which intrigued Rajamouli. His fascination with mythology and the tales of Amar Chitra Katha comics further fueled his interest in the story. However, it took the writers three months to finalise the final draft.
The Legend of King Arthur however is varied but a lot of stories about him follow the premise that the Holy Sword Excalibur (not that one) was inscribed with the legend that the one to pull the sword from the stone it was stabbed into would become the one true king. Many people tried but it wasn't until the youth called Arthur came and successfully pulled Excalibur (not that one) out. Arthur is guided by the Wizard Merlin to become King while accompanied by the like of Guinevere (who would become Arthur's Wife and Queen) and the people who would become his Knights of the Round Table Lancelot, Kay, Bedivere, Galahad, Tristan and many others. Standing in Authur's way however is Merlin's rival, the sorceress Morgan le Fay (or Morganna) who's motivations in the legend range from being Authur's half-sister who wants the throne herself to being a former partner of Merlin's and just wants to see Merlin and Arthur fail. In some versions Arthur's own Nemesis and ally of Morgan's is the Knight Mordred.
While I have not seen Baahubali: The Beginning or King Arthur: Legend of the Sword and not sure what how they are exactly same many can compare other stories to Arthurian legends for common tropes such as:
- sealed holy/magic weapons
- guiding magic man/woman (doesn't always have to show to use magic to the hero)
- the wielder of holy/magic weapons becoming a ruler
Yet they aren't remotely related to or inspired from Arthurian legends.