Science Alert reports about free swimming bottlenose dolphins which work with the U.S. Navy while wearing cameras to record their behavior. What was fascinating to me is that the dolphins are essentially "volunteers."
As for the navy-trained dolphins, they "work in open water almost every day," NMMF explains on their website. "They can swim away if they choose, and over the years a few have. But almost all stay."
The article makes clear the dolphins are not captives in any real sense. I hypothesize the dolphins don't leave because they find humans entertaining and fun, at least much of the time. A cynic would hypothesize some sort of Stockholm syndrome, but I prefer to think being treated as occasionally mischievous pets isn't, as they say in the Navy, "bad duty."
Another factor to consider is that dolphins are herd animals, they belong to a clan, extended family, or social group. Those which swim away abandon their social group. Hat tip to Instapundit for the link.