For those who went into Black Panther without knowing much about the Marvel Cinematic Universe, the film was pretty easy to follow. Unlike many of the Marvel standalone films, there was no McGuffin "Infinity Stone" involved with the adventure, no mention of Thanos, or in-jokes about what happened in previous installments. All the moments that mattered from Black Panther's first appearance in Captain America: Civil War rerun as flashbacks as needed. But one scene would have confused audiences: the post-credit scene. How does Bucky know Black Panther? This is some sort of lead into Infinity War, as the final frame promises that's when Black Panther will return. But how does this tie in? Warning: Spoilers for Black Panther follow.
Let's rewind to the aforementioned Captain America: Civil War. This was the first film where the character of Black Panther was introduced, along with his Dora Milaje guard Ayo. The reason we meet them is that T'Challa's father, T'Chaka is giving a speech to the UN in support of the Sokovia Accords. As we see in the Black Panther flashbacks, this is when T'Chaka is killed.
Immediately the blame falls on the Winter Soldier (Bucky Barnes) as the culprit. The scramble post-explosion follows Steve Rogers (Captain America) telling Bucky to make a run for it. But unbeknownst to the both of them, Black Panther is already on the case, and within the first third of the film, Bucky finds himself in a rooftop showdown with Marvel's newest superhero.
That's not the most pleasant of ways to become acquainted, but with Bucky's Winter Soldier brainwashing kicking in on and off, he might not remember it all that well anyway.
The disagreement over Bucky, and the revelation that he's responsible for several more assassinations while under the Winter Soldier influence — including Tony Stark's parents — is the catalyst for the "Civil War" of the title. Black Panther spends most of it as part of Team Iron Man, not because he's all that fond of Stark, but because he's after Barnes.
In the end, T'Challa sticks around and listens long enough to figure out the truth: Bucky Barnes isn't responsible for his father's death. It's a setup. While Bucky did kill the Stark Family, and countless others, this particular atrocity was the work of Zemo.
While Rogers and Stark are slamming it out over custody of Bucky, T'Challa puts his eyes on the real prize and takes down Zemo, bringing him into custody and justice. That's what he and Everett Ross (another character introduced in Civil War) are discussing in the casino by the way, when T'Challa says Ross owes him because "I gave you Zemo."*
(*Ross counters with "I didn't tell anyone the King of Wakanda runs around in a catsuit fighting crime." You say tomato...)
So how does Bucky wind up in Wakanda? With his name cleared, and his awareness of the depths of his crimes when under the influence of mind control made clear to Barnes over the course of the film, he decides to be put into temporary stasis, while someone works on a cure for what was done to him. Rogers, meanwhile, is determined to find a place that has the technology to save his friend.
The answer for both of them turns out to be Wakanda. To make up to Rogers for siding with Stark, T'Challa offers that as an option. He will take Barnes (and Rogers) back to his home country, where they will find a way to erase the programming and save him.
Thus Bucky Barnes becomes a resident of Wakanda, and under the care of Shuri. He's out of stasis, so obviously she has cured him, but there's still much for him to learn between now and Avengers: Infinity War, coming to theaters on May 4, 2018.